安装nginx、php搭建WordPress

安装NGINX和PHP

参考官方文档:

https://www.php.net/manual/zh/install.unix.nginx.php

https://www.nginx.com/resources/wiki/


安装PHP遇到的问题

问题:no package 'libxml-2.0' found

yum install libxml2-devel


问题:No package 'sqlite3' found

yum install sqlite-devel


问题:ERROR: failed to open configuration file '/usr/local/etc/php-fpm.conf': No such file or directory (2)

cp sapi/fpm/php-fpm.conf /usr/local/etc/


问题:ERROR: Unable to globalize '/usr/local/NONE/etc/php-fpm.d/*.conf' (ret=2) from /usr/local/etc/php-fpm.conf at line 143.

vim /usr/local/etc/php-fpm.conf


改成

include=/usr/local/etc/php-fpm.d/*.conf


问题:cannot get uid for user 'www-data'

groupadd www-data


问题:useradd: group www-data exists - if you want to add this user to that group, use -g.

useradd -g www-data www-data


问题:php访问403 index.php is forbidden (13: Permission denied)

vi /etc/sysconfig/selinux
SELINUX=disabled
chown -R nginx /var/www/html/
chown -R www-data /var/www/html/


在浏览器中访问ip

BF1BCFE2-4DB5-491d-A3DA-4B9A7081AA4F.png


安装WordPress

wordpress官方地址  https://wordpress.org/

安装mysql5 https://www.zhblog.net/python/centos7-mysql5.html


创建数据库

CREATE DATABASE  `pet` DEFAULT CHARACTER SET utf8mb4;


问题:Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

./configure --enable-fpm --with-mysql --with-mysqli


问题:Fatal error: Uncaught Error: Call to undefined function gzinflate() in /var/www/html/wp-includes/class-requests.php:949 Stack trace: #0 /var/www/html/wp-includes/class-requests.php(888):

./configure --with-zlib


问题:413 Request Entity Too Large

server {
    client_max_body_size 100M;
    ...
}


问题:不可生成文件夹

chown -R nginx /var/www/html 
chown -R www-data /var/www/html


折腾了一个下午,总算将WordPress搭建好了。完整编译命令:

./configure --enable-fpm --with-mysql --with-mysqli --with-zlib


 

展开阅读全文