使用Wordpress後臺管理界面,調整Wordpress版式 實現此案例須要按照以下步驟進行。html
步驟一:安裝部署LNMP軟件mysql
備註:mariadb(數據庫客戶端軟件)、mariadb-server(數據庫服務器軟件)、mariadb-devel(其餘客戶端軟件的依賴包)、php(解釋器)、php-fpm(進程管理器服務)、php-mysql(PHP的數據庫擴展包)。nginx
1)安裝軟件包web
- [root@centos7 ~]# yum -y install gcc openssl-devel pcre-devel
- [root@centos7 ~]# useradd -s /sbin/nologin nginx
- [root@centos7 ~]# tar -xvf nginx-1.12.2.tar.gz
- [root@centos7 ~]# cd nginx-1.12.2
- [root@centos7 nginx-1.12.2]# ./configure \
- --user=nginx --group=nginx \
- --with-http_ssl_module \
- --with-http_stub_status_module
- [root@centos7 nginx-1.12.2]# make && make install
- [root@centos7 ~]# yum -y install mariadb mariadb-server mariadb-devel
- [root@centos7 ~]# yum -y install php php-mysql php-fpm
2)啓動服務(nginx、mariadb、php-fpm)sql
- [root@centos7 ~]# /usr/local/nginx/sbin/nginx #啓動Nginx服務
- [root@centos7 ~]# echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
- [root@centos7 ~]# chmod +x /etc/rc.local
- [root@centos7 ~]# ss -utnlp | grep :80 #查看端口信息
- [root@centos7 ~]# systemctl start mariadb #啓動mariadb服務器
- [root@centos7 ~]# systemctl enable mariadb
-
- [root@centos7 ~]# systemctl start php-fpm #啓動php-fpm服務
- [root@centos7 ~]# systemctl enable php-fpm
附加知識:systemd!!!數據庫
源碼安裝的軟件默認沒法使用systemd管理,若是須要使用systemd管理源碼安裝的軟件須要手動編寫服務的service文件(編寫是能夠參考其餘服務的模板文件)。如下是nginx服務最終編輯好的模板。apache
Service文件存儲路徑爲/usr/lib/system/system/目錄。vim
- [root@centos7 ~]# vim /usr/lib/systemd/system/nginx.service
- [Unit]
- Description=The Nginx HTTP Server
- #描述信息
- After=network.target remote-fs.target nss-lookup.target
- #指定啓動nginx以前須要其餘的其餘服務,如network.target等
- [Service]
- Type=forking
- #Type爲服務的類型,僅啓動一個主進程的服務爲simple,須要啓動若干子進程的服務爲forking
- ExecStart=/usr/local/nginx/sbin/nginx
- #設置執行systemctl start nginx後須要啓動的具體命令.
- ExecReload=/usr/local/nginx/sbin/nginx -s reload
- #設置執行systemctl reload nginx後須要執行的具體命令.
- ExecStop=/bin/kill -s QUIT ${MAINPID}
- #設置執行systemctl stop nginx後須要執行的具體命令.
- [Install]
- WantedBy=multi-user.target
3)修改Nginx配置文件,實現動靜分離centos
修改配置文件,經過兩個location實現動靜分離,一個location匹配動態頁面,一個loation匹配其餘全部頁面。
注意修改默認首頁爲index.php!
- [root@centos7 ~]# vim /usr/local/nginx/conf/nginx.conf
- ...省略部分配置文件內容...
- location / {
- root html;
- index index.php index.html index.htm;
- }
- ...省略部分配置文件內容...
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fastcgi.conf;
- }
- ...省略部分配置文件內容...
- [root@centos7 ~]# /usr/local/nginx/sbin/nginx -s reload #從新加載配置
4)配置數據庫帳戶與權限
爲網站提早建立一個數據庫、添加帳戶並設置該帳戶有數據庫訪問權限。
- [root@centos7 ~]# mysql
- MariaDB [(none)]> create database wordpress character set utf8mb4;
- MariaDB [(none)]> grant all on wordpress.* to wordpress@'localhost' identified by 'wordpress';
- MariaDB [(none)]> grant all on wordpress.* to wordpress@'192.168.2.11' identified by 'wordpress';
- MariaDB [(none)]> flush privileges;
- MariaDB [(none)]> exit
提示:在mysql和mariadb中%表明匹配全部,這裏是受權wordpress用戶能夠從任意主機鏈接數據庫服務器,生產環境建議僅容許特定的若干主機訪問數據庫服務器。
步驟二:上線wordpress代碼
1)上線PHP動態網站代碼
- [root@centos7 ~]# unzip wordpress.zip
- [root@centos7 ~]# cd wordpress
- [root@centos7 wordpress]# tar -xf wordpress-5.0.3-zh_CN.tar.gz
- [root@centos7 wordpress]# cp -r wordpress
提示:動態網站運行過程當中,php腳本須要對網站目錄有讀寫權限,而php-fpm默認啓動用戶爲apache。
2)初始化網站配置(使用客戶端訪問web服務器IP)
- [root@client ~]# firefox http: