一、安装 Nginx:
1.下载阿里云镜像中的epel源
阿里云epel源链接 #redhat8版本可能会导致无法安装nginx
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install -y nginx
systemctl start nginx
cd /etc/nginx/
vim nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
include /etc/nginx/default.d/*.conf;
index index.php index.html index.htm; #这一句一定需要加上;为后面进行phpinfo测试
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #$document_root
include fastcgi_params;
}
**#上面一部分location配置与php解析相关,必须存在于nginx配置文件中;否则后面进行php网页测试时会出现无法进行php解析**
保存退出,重启 nginx 服务即可
二、安装php、php-mysql、php-fpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php70w php70w-mysql php70w-fpm
#安装php、php-msqll、php-fpm;如果使用的是AWS版的linux需要先将原有的php-common-5.4.16-46.amzn2.0.2.x86_64卸载掉再安装php70w-mysql
systemctl start php-fpm
#启动php-fpm程序
cd /var/share/nginx/html/
#切换到nginx根目录下
vim test.php
<?php
phpinfo();
?>
#编写测试页文件查看phpinfo信息
yum -y install mariadb-server
systemctl start mariadb
mysql_secure_installation #初始化数据库
mysql -u root -p #进入数据库
create database wordpressdb; #创建数据库名为wordpressdb
create uesr wcl@localhost identified by '8888'; #创建用户wcl;用户密码为8888
prant all privileges on wordpressdb.* to wcl@localhost; #给wcl授权关于wordpressdb所有权限
flush privileges; #更新数据
exit; #退出
三、安装wordpress
1.下载wordpress安装包
wget http://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
2.将wordpress文件夹中的文件移动到/usf/share/nginx/html下
cd wordpress
mv wordpress/* /user/share/nginx/html
3.进入/use/share/nginx/html下;将wordpress中wp- conf-simple.php改成wp-conf.php
cd /user/share/nginx/html
mv wp-conf-simple.php wp-conf.php
vim wp-conf.php
#红色标记分别为:数据库名称、用户名称、用户密码
4.赋予/user/share/nginx/html下所有文件权限,并设置属主和属组为nginx:nginx;或者root:root
chmod -R 777 /user/share/nginx/html/
chown -R nginx:nginx /user/share/nginx/html/
四、在地址栏输入主机Ip:端口号/wp-admin