一、安装nginx
1、更改nginx源安装nginx
#vi /etc/yum.repos.d/nginx.repo
添加以下内容
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
2、开启缓存,安装nginx,备份安装过的包
#vi /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepapache=1
#yum -y install nginx
二、安装php
1、安装php
#vim /etc/yum.repos.d/php.repo
[php-webtatic]
name=PHP Repository
baseurl=http://us-east.repo.webtatic.com/yum/el7/x86_64/gpgcheck=0
#yum install libmcrypt-devel
#yum -y install php71w
3、统一PHP和nginx的用户
#groupadd www -g 666
#useradd www -u666 -g666 -s /sbin/nologin -M
4、让nginx使用www用户
#vi /etc/nginx/nginx.conf
user www;
#systemctl start nginx
#systemctl enable nginx
5、修改php的启动用户,找到相应的匹配用户和组的字段配置即可
#vi /etc/php-fpm.d/www.conf
;Start a new pool named 'www'.
[www]
;unix user/group of processes
;Note: The user is mandatory.If the group is not set, the default user 's group
; will bd used.
; RPM: apache Choosed to be able to access some dir as httpd
user=www
; RPM: Keep a group allowed to write in log dir.
group=www
#systemctl start php-fpm
#systemctl enable php-fpm
三、安装数据库
1、安装数据库
#yum install -y mariadb-server
2、启动服务,开机自启
#systemctl start mariadb
#systemctl enable mariadb
3、设置连接数据库的密码
#mysqldamin -uroot password '123'
4、链接数据库
#mysql -u root -p123
4、创建数据库
MariaDB[(none)]>cretae database wp;
6、查看数据库
MariaDB[(none)]>show database;
7、创建WordPress连接数据库的用户和密码
MariaDB[(none)]>grant all on wp.* to wp_user@'localhost' identified by '111';
#vi /etc/my.conf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip_name_resolve
8、给站点目录授权
#chown www.www/code/php/ -R
#vi index.php
<?php
$servername="localhost";
$username="wq_user";
$password="111";
$conn=mysqli_connect($servername, $username,$password);
if (! $conn) {
die("Connection failed:". mysqld_connect_error()
}
echo "小哥哥,PHP可以连接MYSQL...";
?>
四、使用nginx_http_fastcgi_module
1、使用nginx的ngx_http_fastcgi_module连接php,编辑配置文件
#vi php.conf
2、建立网站目录
#mkdir /code/php -p
#vi /code/php/index.php
五、部署wordpress
1、把WordPress的包解压到网站的主目录下/code/php/,在wordpress的官网上可以下载
#tar -zxvf wordpress-5.4-zh_CN.tar.gz
2、浏览器输入php.gong.com会自动跳转