LNMP 编译安装 Wordpress




Nginx 1.10.3
PHP 5.6
MySQL 5.6

建议使用脚本,可以定义高版本

二进制包已上传至百度云
链接:https://pan.baidu.com/s/1lDmBqadJw_yaYdE50AsV3g 密码:1t96


环境准备

1. 配置repo源和安装常用命令
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install -y net-tools vim wget lrzsz tree screen lsof tcpdump 

2. 关闭防火墙selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

3. 调整文件描述符
echo '*   -    nofile   100000 ' >>/etc/security/limits.conf

5. 更新系统并重启
yum update -y && reboot

安装Nginx

wget http://nginx.org/download/nginx-1.10.3.tar.gz

yum install -y gcc glibc gcc-c++ prce-devel openssl-devel pcre-devel
useradd -s /sbin/nologin www -M 
tar xf nginx-1.10.3.tar.gz && cd nginx-1.10.3

./configure --prefix=/usr/local/nginx-1.10.3 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
make && make install
ln -s /usr/local/nginx-1.10.3 /usr/local/nginx




手动启动
/usr/local/nginx/sbin/nginx

设置开机启动
echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local


查看服务器是否启动
netstat -lntp|grep nginx
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7058/nginx: master

PHP5.6安装

php下载目录:http://php.net/downloads.php


安装
当我们下载完软件包直接rz上传

php下载目录:http://php.net/downloads.php

上传软件包
rz


安装PHP基础库
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel



需要先安装支持的软件包
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install


PHP相关扩展库
yum -y install libmcrypt-devel
yum -y install mhash
yum -y install mcrypt
yum -y install libmcrypt-devel
yum -y install bzip2-devel readline-devel

安装php mcrypt
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make && make install

错误文档
编译libiconv-1.14解决./stdio.h:1010:1: 错误: ‘gets’未声明(不在函数内)错误

安装php
[root@abcdocker ~]# tar xf php-5.6.38.tar.gz && cd php-5.6.38

编译
 ./configure \
--prefix=/usr/local/php5.6.30 \
--with-config-file-path=/usr/local/php56/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-opcache=yes \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--enable-zip \
--with-bz2 \
--with-libdir=lib64 \
--with-readline

##编译出问题可以参考https://www.abcdocker.com/abcdocker/2911


编译
[root@abcdocker ~]# make && make install
[root@abcdocker ~]# ln -s /usr/local/php5.6.30/  /usr/local/php
[root@abcdocker ~]# cp ./php.ini-development /usr/local/php/lib/php.ini
[root@abcdocker ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

手动启动php
[root@abcdocker ~]# /usr/local/php/sbin/php-fpm

设置开机启动
手动启动
[root@abcdocker ~]# echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local

MySQL 5.6安装

安装目录:/usr/local/mysql5.6
数据库目录 : /data/mysql/data
mysql安装包:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz

1.创建用户
useradd -s  /sbin/nologin mysql

2.创建安装和数据库目录
mkdir -p /usr/local/mysql5.6
mkdir -p /data/mysql/data
chown -R   mysql:mysql /data/mysql

3.安装编译mysql所需的程序或文件:
yum install gcc gcc-c++ cmake ncurses-devel bison -y

4.编译
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz 
tar xf mysql-5.6.23.tar.gz && cd mysql-5.6.23

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6 -DMYSQL_DATADIR=/data/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

5.编译完成后执行
make && make install

静静的等待….等到MySQL安装完成。

安装完成设置软连接

ln -s /usr/local/mysql5.6/ /usr/local/mysql

执行初始化命令

cd /usr/local/mysql/scripts
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

初始化Mysql报错
FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:

解决办法
yum -y install autoconf

启动MySql

cp /usr/local/mysql5.6/support-files/my-default.cnf  /etc/my.cnf
cp /usr/local/mysql5.6/support-files/mysql.server  /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
Starting MySQL. SUCCESS!

[root@abcdocker scripts]# lsof -i:3306
COMMAND   PID  USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
mysqld  20438 mysql   10u  IPv6 32904948      0t0  TCP *:mysql (LISTEN)

echo "export PATH=/usr/local/mysql/bin/:$PATH" >> /etc/profile
source /etc/profile

修改my.cnf配置文件

vim /etc/my.cnf

basedir=/usr/local/mysql
datadir=/data/mysql/data

如下图

重启MySQL

/etc/init.d/mysqld restart

检查


WordPress 安装

1.创建MySQL用户及存储库

mysql
create database wordpress;
grant all privileges on wordpress.* to 'wordpress'@localhost identified by '123456';
flush privileges;
exit

2.设置Nginx Conf

[root@abcdocker conf]# >/usr/local/nginx/conf/nginx.conf
[root@abcdocker conf]# vim /usr/local/nginx/conf/nginx.conf
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;

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

        location ~ .*\.(php|php5)?$ {
            root html;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi.conf;
        }
 }
 }

重启Nginx

[root@abcdocker conf]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.10.3/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.10.3/conf/nginx.conf test is successful

[root@abcdocker conf]# /usr/local/nginx/sbin/nginx -s reload

下载Wordpress

cd /usr/local/nginx/html
rm -rf *
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.zip
unzip wordpress-4.9.4-zh_CN.zip
mv wordpress/* .
chown -R www.www /usr/local/nginx/html/
chmod -R 777 wp-content

浏览器访问

解决wordpress安装主题或插件需要FTP问题