基础组件:lnmp Linux,nginx ,mysql ,php
官方安装文档:
https://wordpress.org/support/article/how-to-install-wordpress/
安装过程
版本:5.2.5
yum install mysql-server nginx -y
安装mysql 和 nginx
mysql安装初始化:
mysql_secure_installation
创建数据库:
mysql -uuser -ppassword -e “create databases wordpress;”
授权:
mysql -uuser -ppassword -e “GRANT ALL PRIVILEGES ON wordpress
.* TO ‘dbuser’@‘localhost’;”
创建数据库
wordpress nginx配置规则
参考:https://blog.csdn.net/jun4331247/article/details/80738736
官网: https://wordpress.org/support/article/nginx/#general-wordpress-rules
upstream php {
server unix:/tmp/php-cgi.socket;
server 127.0.0.1:9000;
}
server {
listen 80;
## Your website name goes here.
server_name 192.168.119.110;
## Your only path reference.
root /data/app/wordpress;
## This should be in your http block and if it is, it's not needed here.
index index.php;
access_log /data/log/nginx/wordpress.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
安装 php php-fpm
如果输入http://example.com/blog/wp-admin/install.php 不是打开网页而是直接下载php文件,说明没有安装php-fpm
php 版本太低,解决方案:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm #更新源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum remove php-common -y #移除系统自带的php-common
yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring
安装php-fpm :
yum install php72w-fpm
启动php-fpm
systemctl start php-fpm
然后在web页面输入:http://192.168.119.110/wp-admin/install.php 根据提示填入数据库库名、账号密码、地址等,依次安装即可