LNMP项目实战:
L:Linux(centos 7.6) http://mirrors.cqu.edu.cn/CentOS/7.6.1810/isos/x86_64/
N:Nginx(1.12.2) https://nginx.org/en/download.html
M:MySQL(5.6.43) https://dev.mysql.com/downloads/mysql/5.6.html#downloads
P:PHP(7.2.15) http://php.net/downloads.php
Worldpress(5.0.3):https://cn.wordpress.org/download/

-----
准备虚拟机型

192.168.55.3 nginx php-fpm
192.168.55.5 mysql
准备的包****
mariadb-10.2.23-linux-x86_64.tar.gz
wordpress-5.2.tar.gz
xvf php-7.3.2.tar.xz
nginx-1.12.2.tar.gz
编译MySQL
1 准备用户和组
groupadd -r -g 336 mysql 创建一个用户组 gid为336
useradd -r -g mysql -u 336 -s /sbin/nologin -d /data/mysql mysql
创建用户 gid为336 -s shell类型 创建目录

2 准备二进制程序文件和相关文件属性
tar xvf mariadb-10.2.23-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mariadb-10.2.23-linux-x86_64/ mysql
chown -R root.root /usr/local/mysql/

3 PATH变量
cat /etc/profile.d/mysql.sh
PATH=/usr/local/mysql/bin:$PATH

4 准备数据库数据目录和数据
mkdir /data/mysql -pv
chown mysql.mysql /data/mysql/
cd /usr/local/mysql
./scripts/mysql_install_db --datadir=/data/mysql --user=mysql

5 准备Mysql的服务器端的配置文件
mkdir /etc/mysql
cp /usr/local/mysql/support-files/my-huge.cnf /etc/mysql/my.cnf
vim /etc/mysql/my.cnf
[mysqld]
datadir=/data/mysql 加一行

6 准备服务启动脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld 把mysqld加入进程
service mysqld start

7进去mysql并且创建wordpress数据库 用户 授权
创建数据库
CREATE DATABASE wordpress;
创建php连接数据库的用户
create user 'wordpress' @'192.168.55.3' identified by '123456';
授权192.168.55.3用户登陆
GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"192.168.55.3" IDENTIFIED BY "123456";
FLUSH PRIVILEGES;
编译安装php
1 解压
tar xvf php-7.3.2.tar.xz
2安装php所需要的源
yum install libxml2-devel bzip2-devel libmcrypt-devel -y
yum install openssl-devel.x86_64
3进入php目录下编译
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
make -j 4 && make install
4 修改配置文件
cd /app/php/etc/php-fpm.d/
cp www.conf.default www.conf
cp /data/php-7.3.5/php.ini-production /app/php/etc/php.ini
5添加用户用户组
useradd www -s /sbin/nologin -u 1001
6grep -v ";" www.conf | grep -v "^$"

7设置配置内容
mdkir /app/php/log/ 日志文件路径
cd /app/php/etc/
cp php-fpm.conf.default php-fpm.conf
7检查语法并且启动php
/app/php/sbin/php-fpm -t
/app/php/sbin/php-fpm -c /app/php/etc/php.ini
ps -ef |grep php-fpm
netstat -tanlp | grep php-fpm
编译安装nginx
1 下载nginx需要的文件
yum install -y vim lrzsz tree screen psmisc lsof tcpdump wget ntpdate gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel net-tools iotop bc zip unzip zlib-devel bash-completion nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed
2 解压nginx包
cd /usr/local/src/
tar xvf nginx-1.12.2.tar.gz
cd nginx-1.12.2/
3编译安装
./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
编译开始
make
创建目录,并将生成的模块和文件复制到相应的目录
make install
mkdir /data/nginx/wordpress -p
4准备php测试页面
[root@s1 ~]# vim /data/nginx/wordpress/index.php
phpinfo();
?>

配置nginx
grep -v "#" /application/nginx-1.14.2/conf/nginx.conf | grep -v "^$"

cat /apps/nginx-1.12.2/conf/nginx.conf
server {
listen 80;
server_name www.magedu.net;
location / {
root /data/nginx/wordpress;
index index.php index.html index.htm;
if ($http_user_agent ~ "ApacheBench|WebBench|TurnitinBot|Sogou web
spider|Grid Service") {
#proxy_pass http://www.baidu.com;
return 403;
}
}
location ~ .php$ {
root /data/nginx/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

部署wordpress
cd /data/nginx/wordpress/
mv index.php /opt/
解压wordpress
tar xvf wordpress-5.2.tar.gz
mv wordpress/* .
mv wordpress wordpress-5.2.tar.gz /opt/
cp wp-config-sample.php wp-config.php
修改wp-config.php 配置文件
vim /data/nginx/wordpress/wp-config.php
// MySQL 设置 - 具体信息来自您正在使用的主机 //
/ WordPress数据库的名称 */
define('DB_NAME', 'wordpress');
/* MySQL数据库用户名 /
define('DB_USER', 'wordpress');
/
MySQL数据库密码 */
define('DB_PASSWORD', '123456');
/* MySQL主机 /
define('DB_HOST', '192.168.55.5');
更改所属组
chown www.www /data/nginx/wordpress/ apps/nginx/ -R
/apps/nginx/sbin/nginx -s reload

访问web页面
http://www.magedu.net/index.php