部署Nginx:
1.配置官网仓库
[root@web01 conf.d]# cat /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
[root@web01 ~]# yum -y install nginx
3.启动并加入开机自启
[root@web01 ~]# systemctl start nginx
[root@web01 ~]# systemctl enable nginx
4.安装PHP服务
配置官网仓库
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装PHP服务: 直接YUM安装 网络条件好
yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb --nogpgcheck
--------------------------------------------------------------
#配置第三方源
[root@nginx ~]# 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
----------------------------------------------------------------------------
只下载不安装yumdownloader
默认路径
--downloaddir=指定下载路径
yum -y install xxx --downloadonly --downloaddir=./ -y
-----------------------------------------------------------------------------
第二种安装方式: 通过本地rpm包进行安装
上传tar.gz php安装包
解压到oldboy目录
tar xf php.tar.gz -C oldboy/
本地安装:
[root@web01 oldboy]# yum -y localinstall ./*.rpm
启动PHP服务加入开机自启:
[root@web01 ~]# systemctl start php-fpm
[root@web01 ~]# systemctl enable php-fpm
启动后检查端口: 9000
[root@web01 ~]# netstat -tnulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 31437/php-fpm: mast
5. 安装数据库mariadb
[root@web01 ~]# yum -y install mariadb-server
启动数据库:
[root@web01 ~]# systemctl start mariadb
[root@web01 ~]# systemctl enable mariadb
[root@web01 ~]# netstat -tnulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 31437/php-fpm: mast
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 31771/mysqld
设置数据库密码为lzy123.com 默认密码为空
[root@web01 ~]# mysqladmin password 'lzy123.com'
登陆数据测试:
[root@web01 ~]# mysql -uroot -plzy123.com
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> quit # 退出数据库
业务配置:
第一步:
创建server
[root@web01 conf.d]# cat wordpress.conf
server {
listen 80;
server_name wordpress.oldboy.com;
location / {
root /code/wordpress/;
index index.php index.html;
}
location ~ \.php$ {
root /code/wordpress/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
重启:
[root@web01 wordpress]# systemctl restart nginx
什么情况下需要重启:在新增加nginx配置文件
什么情况下重新加载: 只修改配置文件直接加载 reload
修改代码不需要重启 不需要加载
第二步:
根据配置文件创建必要信息:
[root@web01 conf.d]# mkdir /code/wordpress/
第三步:
下载博客代码放到code/wordpress/
博客官网地址:https://cn.wordpress.org/download/
[root@web01 conf.d]# cd /code/wordpress/
[root@web01 wordpress]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
解压代码:
[root@web01 wordpress]# tar xf latest-zh_CN.tar.gz
[root@web01 wordpress]# ll
total 21376
-rw-r--r-- 1 root root 21881579 Jun 16 14:00 latest-zh_CN.tar.gz
drwxr-xr-x 5 1006 1006 4096 Jun 16 14:00 wordpress
[root@web01 wordpress]# rm -rf latest-zh_CN.tar.gz
[root@web01 wordpress]# mv wordpress/* .
第四步: windows做hosts解析
wordpress.oldboy.com 10.0.0.7
第五步: 通过浏览器访问wordpress.oldboy.com 进行安装部署业务
授权/code/wordpress 属主属组为php的启动用户apache
chown -R apache.apache /code/wordpress
在安装过程需要数据库: 必须手动创建数据库 wordpress
创建wordpress库
[root@web01 ~]# mysql -uroot -plzy123.com -e "create database wordpress;"
检查wordperss库
[root@web01 ~]# mysql -uroot -plzy123.com -e "show databases;"
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| wordpress |
+--------------------+
继续安装配置:
数据库名称: wordpress
数据库地址: localhost
数据库用户: root
数据库密码: lzy123.com
wordpress的后台管理连接:http://wordpress.oldboy.com/wp-admin/
删除所有PHP相关的软件:
[root@web01 ~]# rpm -qa |grep php|xargs yum -y remove