基于 LNMP 搭建WordPress(编译)

环境

系统:CentOS7
IP:192.168.253.128
Nginx版本:1.14
PHP版本:7.0.31
MySQL版本:5.6.39
WordPress版本:wordpress-4.9.4-zh_CN
关闭防火墙和selinux

systemctl  stop firewalld 
setenforce  0

第一步:部署Nginx

可以官网下对应的tar包 http://nginx.org/en/download.html
然后将下载的tar包放在/usr/local/src/目录下

yum install openssl openssl-devel gcc gcc-devel pcre pcre-devel -y
useradd -M -s /sbin/nologin nginx
cd /usr/local/src/
tar -xf nginx-1.14.0.tar.gz 
cd nginx-1.14.0
./configure --prefix=/usr/local/nginx1.14 --user=nginx --group=nginx --with-http_ssl_module  --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-threads --with-file-aio
make && make install 
ln -sv /usr/local/nginx1.14  /usr/local/nginx
PATH=/usr/local/nginx/sbin/:$PATH
chown -R nginx:nginx /usr/local/nginx1.14

验证一下

nginx  

基于 LNMP 搭建WordPress(编译)_第1张图片
基于 LNMP 搭建WordPress(编译)_第2张图片

第二步:部署php-fpm

tar包可以再官网下 http://www.php.net/downloads.php

cd /usr/local/src/
tar -zxf php-7.0.31.tar.gz 
cd php-7.0.31
yum install  zlib libxml libjpeg freetype  libpng  gd curl  libiconv zlib-devel  libxml2-devel libjpeg-devel freetype-devel  libpng-devel gd-devel curl-devel bzip2 bzip2-devel  -y
./configure --prefix=/usr/local/php7.0  --with-openssl  --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets    --with-bz2  --with-mysqli=mysqlnd --enable-fpm --with-pdo-mysql=mysqlnd
make && make install 
cp /usr/local/src/php-7.0.31/php.ini-production  /usr/local/php7.0/lib/php.ini
cp /usr/local/php7.0/etc/php-fpm.conf.default /usr/local/php7.0/etc/php-fpm.conf
cp /usr/local/php7.0/etc/php-fpm.d/www.conf.default  /usr/local/php7.0/etc/php-fpm.d/www.conf
ln -sv /usr/local/php7.0 /usr/local/php
PATH="/usr/local/php/sbin/:$PATH"
chown -R nginx:nginx /usr/local/php7.0

修改php-fpm配置文件/usr/local/php/etc/php-fpm.d/www.conf

user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx

启动php-fpm

php-fpm

基于 LNMP 搭建WordPress(编译)_第3张图片
修改Nginx配置文件/usr/local/nginx/conf/nginx.conf

[root@localhost html]# cat /usr/local/nginx/conf/nginx.conf
user  nginx;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        root /var/www/html;

        location / {
            index  index.html index.htm;
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
            include        fastcgi_params;
        }

    }
}

创建一个php的测试页面

mkdir -pv /var/www/html
echo -e "" > /var/www/html/index.php
chown -R nginx:nginx /var/www/html

重载一下Nginx的配置文件

nginx  -s  reload

基于 LNMP 搭建WordPress(编译)_第4张图片

基于 LNMP 搭建WordPress(编译)_第5张图片
测试完了记得删除测试文件,不然暴露在公网的信息太多很危险。

第三步:部署MySQL

二进制包可以去官网下载 https://dev.mysql.com/downloads/mysql/

yum install perl-Data-Dumper -y
useradd -M -s /sbin/nologin mysql
cd /usr/local/src
tar -xf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql5.6
chown -R mysql.mysql /usr/local/mysql5.6
ln -sv /usr/local/mysql5.6/ /usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
PATH=/usr/local/mysql/bin/:$PATH
echo 'PATH="/usr/local/mysql/bin/:$PATH"' > /etc/profile.d/mysql.sh

修改配置文件/etc/my.cnf

[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
symbolic-links=0

[mysqld_safe]
log-error=/usr/local/mysql/data/log-err.log
pid-file=/usr/local/mysql/data/mysql.pid

!includedir /etc/my.cnf.d

启动

mysqld_safe  &

基于 LNMP 搭建WordPress(编译)_第6张图片

创建WordPress数据库和用户

mysql -uroot -e "create database wordpress;"
mysql -uroot -e "grant all on wordpress.* to 'wordpress'@'127.0.0.1' identified by 'wordpress';"

第四步:部署WordPress

压缩包官网可以下 https://cn.wordpress.org/download/

yum install unzip -y
unzip wordpress-4.9.4-zh_CN.zip
mv wordpress /var/www/html/
chown -R nginx:nginx  /var/www/html

重启nginx

nginx -s stop 
nginx

基于 LNMP 搭建WordPress(编译)_第7张图片
然后按部就班就可以了
基于 LNMP 搭建WordPress(编译)_第8张图片
基于 LNMP 搭建WordPress(编译)_第9张图片

基于 LNMP 搭建WordPress(编译)_第10张图片

基于 LNMP 搭建WordPress(编译)_第11张图片

你可能感兴趣的:(Nginx)