使用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: