利用LNMP实现wordpress站点搭建
1. ansible安装
1.1 epel安装配置
此处略.参见
https://blog.csdn.net/qq_29974229/article/details/119447901
1.2 ansible 安装
yum install -y ansible
2. mariadb安装
此处略,参见
https://blog.csdn.net/qq_29974229/article/details/120329530
3. 编译安装Nginx
此处略,详见
https://blog.csdn.net/qq_29974229/article/details/121266195
文中1-3
4. Php安装及转发配置
4.1 php安装
yum install -y php-fpm php-mysqlnd php-json
sed -Ei 's#^(listen = )\/run\/php-fpm\/www.sock#\19000#g' /etc/php-fpm.d/www.conf
sed -Ei 's/^(listen.allowed_clients.*)/;\1/g' /etc/php-fpm.d/www.conf
systemctl enable --now php-fpm.service
mkdir /apps/nginx/conf/conf.d/ -p
4.2 PHP配置
mkdir -p /apps/nginx/conf/conf.d
mkdir -p /data/bbs/wordpress
chown nginx.nginx -R /data
cat >> /apps/nginx/conf/nginx.conf<<EOF
user nginx;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name wordpress;
access_log logs/host.access.log main;
location / {
root /data/bbs/wordpress;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root /data/bbs/wordpress;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/(ping|pm_status)$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
}
}
}
EOF
4.3 PHP测试页
cat >> /data/bbs/wordpress/html/123.php <<EOF
<?php
phpinfo();
?>
EOF
5. Wordpress安装
cd /data/
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar xf latest-zh_CN.tar.gz -C /data/bbs/
chown nginx.nginx -R /data/bbs/