1).访问方式:http: //ip/blog
2).账号:admin
密码:OpDccvC7gVjwoWu700
3).wordpress版本:6.0
4).主题/插件:可以通过可视化界面添加任意主题/插件
5).安装两个PHP版本,可以实现版本切换
1).Linux:centOS 7.6
2).Nginx:1.20.1
3).Mysql:5.7.38
4).PHP:7.4.28 and 7.3.28
1).关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
2).关闭selinux
setenforce 0
vim /etc/sysconfig/selinux
yum -y install nginx
nginx -v # 查看nginx版本
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql-community-server --nogpgcheck
mysql -V # 查看mysql版本
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload
在/usr/local目录下创建php7.4目录
mkdir -p /usr/local/php7.4
安装依赖包
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel sqlite-devel oniguruma-devel
下载并解压php7.4.28源码包
wget https://www.php.net/distributions/php-7.4.28.tar.gz
tar zxvf php-7.4.28.tar.gz
进入php-7.4.28/目录
cd php-7.4.28/
配置变量
./configure -prefix=/usr/local/php7.4 -with-zlib-dir -enable-mbstring -enable-soap -enable-calendar -with-curl -disable-rpath -enable-inline-optimization -with-bz2 -with-zlib -enable-sockets -enable-sysvsem -enable-sysvshm -enable-pcntl -enable-mbregex -enable-exif -enable-bcmath -with-mhash -with-pdo-mysql -with-mysqli -with-openssl -with-fpm-user=nobody -with-fpm-group=nobody -enable-ftp -with-gettext -with-xmlrpc -with-xsl -enable-opcache -enable-fpm -with-iconv
编译安装(时间较长,耐心等待)
make all install
检查编译安装结果
make test
cp /usr/local/php7.4/etc/php-fpm.conf.default /usr/local/php7.4/etc/php-fpm.conf
cp /usr/local/php7.4/etc/php-fpm.d/www.conf.default /usr/local/php7.4/etc/php-fpm.d/www.conf
ps -ef |grep php-fpm
进入php7.4.28配置文件,修改配置
vim /usr/local/php7.4/etc/php-fpm.d/www.conf
启动php7.4.28
/usr/local/php7.4/sbin/php-fpm
在/usr/local目录下创建php7.3目录
mkdir -p /usr/local/php7.3
安装依赖包(7.4.28已安装过,无需重复安装)
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel sqlite-devel oniguruma-devel
返回到根目录
cd ~
下载并解压php7.3.28源码包
wget https://www.php.net/distributions/php-7.3.28.tar.gz
tar zxvf php-7.3.28.tar.gz
进入php-7.3.28/目录
cd php-7.3.28/
配置变量
./configure -prefix=/usr/local/php7.3 -with-zlib-dir -enable-mbstring -enable-soap -enable-calendar -with-curl -disable-rpath -enable-inline-optimization -with-bz2 -with-zlib -enable-sockets -enable-sysvsem -enable-sysvshm -enable-pcntl -enable-mbregex -enable-exif -enable-bcmath -with-mhash -with-pdo-mysql -with-mysqli -with-openssl -with-fpm-user=nobody -with-fpm-group=nobody -enable-ftp -with-gettext -with-xmlrpc -with-xsl -enable-opcache -enable-fpm -with-iconv
编译安装(时间较长,耐心等待)
make all install
检查编译安装结果
make test
cp /usr/local/php7.3/etc/php-fpm.conf.default /usr/local/php7.3/etc/php-fpm.conf
cp /usr/local/php7.3/etc/php-fpm.d/www.conf.default /usr/local/php7.3/etc/php-fpm.d/www.conf
ps -ef |grep php-fpm
进入php7.3.28配置文件,修改配置
vim /usr/local/php7.3/etc/php-fpm.d/www.conf
启动php7.3.28
/usr/local/php7.3/sbin/php-fpm
在 /etc/nginx/conf.d/ 目录下创建wordpress的配置文件
vim /etc/nginx/conf.d/wordpress.conf
将下列配置文件复制粘贴到wordpress.conf中
server {
listen 80;
server_name 127.0.0.1;
access_log /usr/local/nginx/logs/wordpress/access2.log main;
error_log /usr/local/nginx/logs/wordpress/error2.log;
root /wordpress/wordpress_01/blog/;
error_page 500 502 503 504 /50x.html;
location test/ {
rewrite ^test(.*)$ wp-admin$1 last;
}
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$uri&$args;
}
location = /50x.html {
root html;
}
location ~ ^(.+\.php)(.*)$ {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass 127.0.0.1:9001; # 配置一个php不需要这一行
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
fastcgi_buffers 8 128k;
fastcgi_connect_timeout 300;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
}
}
手动创建日志目录
mkdir -p /usr/local/nginx/logs/wordpress/
手动创建日志文件
vim /usr/local/nginx/logs/wordpress/access2.log
vim /usr/local/nginx/logs/wordpress/error2.log
启动Nginx
systemctl start nginx
systemctl enable nginx
systemctl status nginx
运行以下命令查看/var/log/mysqld.log文件,获取并记录root用户的初始密码。
grep 'temporary password' /var/log/mysqld.log
运行以下命令配置MySQL的安全性。
mysql_secure_installation
输入初始密码,然后根据提示输入新密码(新密码要求大小写数字特殊符号都要有,否则会提示重置密码错误),碰到选项一律选y
登录mysql数据库
mysql -uroot -p‘你设置的密码’
创建数据库
create database wordpress_01;
创建数据库用户
create user admin@'%' identified by '你设置的密码';
数据库wordpress_kol_kr_02授权
grant all privileges on wordpress_01.* to admin@你自己的ip地址 identified by '你设置的密码';
刷新系统权限表
flush privileges;
下载wordpress
wget -P /wordpress https://cn.wordpress.org/wordpress-6.0-zh_CN.zip
进入下载目录
cd /wordpress
解压
unzip wordpress-6.0-zh_CN.zip
mkdir -p ./wordpress_01/blog
mv ./wordpress/* ./wordpress_01/blog
点击现在就开始
可能出现以下报错,只需要按照提示创建文件即可(注意在文件末尾加上 ?> 复制进去的没有带)
解决报错后,进入以下界面,配置完成后,点击安装
安装成功
报错信息
解决方法:在nginx子配置文件里添加伪静态规则
把下面的 blog 改成你二级目录的名字添加到虚拟主机配置文件里面即可。
location /blog/ {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /blog/index.php;
}
}
rewrite /blog/wp-admin$ $scheme://$host$uri/ permanent;
修改完成后重启nginx
systemctl restart nginx
define("FS_METHOD","direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);
然后把worpress的属主属组改为www.www
chown -R www.www /wordpress