一、Linux部署
- 安装CentOS7系统
- 配置YUM源
- 关闭防火墙
二、Nginx部署
配置官方YUM源,链接nginx: Linux packages
[root@localhost ~]# vim /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
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
搜索nginx包
[root@localhost ~]# yum list | grep nginx
nginx.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-debug.x86_64 1:1.8.0-1.el7.ngx nginx-stable
nginx-debuginfo.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-geoip.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-geoip-debuginfo.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-image-filter.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-image-filter-debuginfo.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-njs.x86_64 1:1.24.0+0.8.3-1.el7.ngx nginx-stable
nginx-module-njs-debuginfo.x86_64 1:1.24.0+0.8.3-1.el7.ngx nginx-stable
nginx-module-perl.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-perl-debuginfo.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-xslt.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-module-xslt-debuginfo.x86_64 1:1.24.0-1.el7.ngx nginx-stable
nginx-nr-agent.noarch 2.0.0-12.el7.ngx nginx-stable
pcp-pmda-nginx.x86_64 4.3.2-13.el7_9 updates
安装nginx
[root@localhost ~]# yum install -y nginx.x86_64
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl enable nginx
三、php-fpm部署
[root@localhost ~]# yum install -y php-fpm php-mysql php-gd
[root@localhost ~]# systemctl start php-fpm
[root@localhost ~]# systemctl enable php-fpm
[root@localhost ~]# netstat -anpt | grep 9000 # php-fpm默认端口为9000
修改nginx配置
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
#修改
location / {
root /usr/share/nginx/html;
index index.php index.html; # 添加了index.php
}
# 添加或去掉注释
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;
include fastcgi_params;
}
重启nginx
[root@localhost conf.d]# systemctl restart nginx
四、mysql部署
检查系统里是否有mariadb
[root@localhost ~]# rpm -qa | grep mariadb
删除mariadb
[root@localhost ~]# rpm -e --nodeps mariadb-libs
下载三个相关软件
[root@localhost ~]# yum install -y net-tools.x86_64 libaio.x86_64 perl.x86_64
创建一个文件夹,用来存放mysql的RPM包
[root@localhost ~]# mkdir /root/mysql57
[root@localhost ~]# cd /root/mysql57
下载mysql的RPM包,直接复制下面的命令即可
[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.25-1.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.25-1.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.25-1.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.25-1.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm
下载好以后就是下面五个包
安装mysqll
[root@localhost ~]# yum install -y /root/mysql57/*rpm
启动mysql
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
查看mysql初始密码
[root@localhost ~]# grep password /var/log/mysql.log
进入mysql
[root@localhost ~]# mysql -uroot -p'M1lo-qPgj;#U'
创建一个库
mysql> create databases bbs;
创建数据库用户
mysql> create user phptest@'192.168.130.%' identified by '密码';
给创建的用户授权
mysql> grant all on bbs.* to phptest@'192.168.130.%';
五、安装WordPress
下载wordpress的压缩包
[root@localhost ~]# wget https://cn.wordpress.org/wordpress-4.9.1-zh_CN.zip
下载解压工具
[root@localhost ~]# yum install -y unzip
解压wordpress
[root@localhost ~]# unzip wordpress-4.9.1-zh_CN.zip
将wordpress放到nginx的html文件下,并修改权限
[root@localhost ~]# cp -rf /root/wordpress/* /usr/share/nginx/html/
[root@localhost ~]# chown -R nginx.nginx /usr/share/nginx/html/*
[root@localhost ~]# chmod 777 /usr/share/nginx/html
六、对网站进行设置
登录网站
浏览器访问http://192.168.130.129/ #192.168.130.129就是我们上面操作的这台机器的IP
单击开始配置
填写配置
填写配置
部署成功