框架描述: Lamp=Linux+Apache+MySQL(mariadb)+PHP
linux:CentOS7.6.1810
Apache:Web前端服務(wù)
MySQL(mariadb):后臺數(shù)據(jù)庫
PHP:后端開發(fā)語言
1.下載所需要的安裝包并啟動服務(wù)
[root@localhost ~]#yum -y install httpd mariadb mariadb-server php php-mysql gd php-gd
[root@localhost ~]#systemctl start httpd mariadb
注:MySQL數(shù)據(jù)庫與mariadb數(shù)據(jù)庫兩者內(nèi)核基本一樣辑莫,mariadb數(shù)據(jù)庫安裝簡單
2.進(jìn)入數(shù)據(jù)庫并創(chuàng)建boke庫(名字自定義我這里用boke,也可以設(shè)置成wordpress)
[root@localhost ~]#mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 384
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database boke;
MariaDB [(none)]>quit
3.下載并上線wordpress
[root@localhost ~]#wget http://cn.wp101.net/wordpress-5.0.3-zh_CN.zip -O /root
[root@localhost ~]#unzip wordpress-5.3.2.zip
注:沒有unzip命令的可以yum -y install unzip下載
4.刪除/var/www/html/下的所有文件
[root@localhost ~]#rm -rf /var/www/html/*
5.將解壓縮得到的wordpress下的所有文件復(fù)制到/var/www/html/目錄下
[root@localhost ~]#cp -r /root/wordpress/* /var/www/html/
6.設(shè)置var/www/html/目錄下的文件所有者權(quán)限并重啟服務(wù)
[root@localhost ~]#chown -R apache.apache /var/www/html/
[root@localhost ~]#systemctl start httpd mariadb
注:不給var/www/html/目錄下的文件777權(quán)限是因為權(quán)限太大怀酷、不安全
7.瀏覽器登陸前的準(zhǔn)備工作
本地主機(jī)(關(guān)閉防火墻瞬痘、關(guān)閉SElinux)
[root@localhost ~]#systemctl stop firewalld.service
[root@localhost ~]#setenforce 0
[root@localhost ~]#getenforce
Permissive
云主機(jī)(設(shè)置安全組)
8.瀏覽器登陸(主機(jī)IP)
本地數(shù)據(jù)庫
這里缺少一個現(xiàn)在安裝的過程
9.用shell腳本實現(xiàn)自動化(云验毡、本地都適用)
[root@localhost ~]#mkdir lamp
[root@localhost ~]#cd lamp
[root@localhost lamp]#vim lamp.sh
#!/bin/bash
yum -y install httpd mariadb mariadb-server php php-mysql gd php-gd &>/dev/null
if [$? -eq 0];then
echo "軟件包安裝完畢"
else
echo "軟件包安裝異常"
exit
fi
systemctl start httpd mariadb
if [$? -eq 0];then
echo "軟件啟動正常"
else
echo "軟件啟動異常"
exit
fi
wget http://cn.wp101.net/wordpress-5.0.3-zh_CN.zip -O /root/lamp/ &>/dev/null
if [$? -eq 0];then
echo "wordpress包下載完畢"
else
echo "wordpress包下載異常升熊,請手動下載并上傳到/root/lamp/目錄下"
exit
fi
yum -y install unzip
unzip /root/lamp/wordpress-5.0.3-zh_CN.zip
if [$? -eq 0];then
echo "wordpress包解壓完畢"
else
echo "wordpress包解壓異常虚青,請查看/root/lamp/目錄下是否有wordpress-5.0.3-zh_CN.zip包"
exit
fi
rm -rf /var/www/html/*
cp -r /root/lamp/wordpress/* /var/www/html/
chown -R apache.apache /var/www/html/
systemctl start httpd mariadb
if [$? -eq 0];then
echo "重啟服務(wù)正常"
else
echo "重啟服務(wù)出異常"
exit
fi
mysql -uroot -e "create database boke;"
if [$? -eq 0];then
echo "數(shù)據(jù)庫添加boke庫正常"
else
echo "數(shù)據(jù)庫添加boke庫異常"
exit
fi
echo "腳本執(zhí)行完畢"
[root@localhost lamp]#chomd +x lamp.sh
[root@localhost lamp]#./lamp.sh