要使用官方Nginx源,无需手动编译避免繁琐操作。
手动配置yum源
[root@nginx~]vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
执行yum安装
[root@nginx ~]# yum install nginx -y
启动nginx并加入开机自启
[root@nginx ~]# systemctl start nginx
[root@nginx ~]# systemctl enable nginx
移除旧版php
[root@nginx ~]# yum remove php-mysql-5.4 php php-fpm php-common -y
配置扩展源
[root@nginx nginx]# yum localinstall -y http://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php7.1版
[root@nginx ~]# 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
统一系统权限,修改php-fpm运行的用户和组身份
[root@web02 ~]# sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf
[root@web02 ~]# sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf
启动php-fpm管理进程,并加入开机自启
root@nginx ~]# systemctl start php-fpm
[root@nginx ~]# systemctl enable php-fpm
[root@nginx conf.d]# cat /etc/nginx/conf.d/blog.michaelxia.conf
server {
listen 80;
server_name test.michaelxia.com;
location {
root /code/test;
index index.php index.html;
}
location ~ \.php$ {
root /code/test;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[root@Nginx conf.d]# mkdir /code/test
[root@Nginx conf.d]# vim /code/test/index.php
######该文件内容为测试php成功连接
phpinfo();
?>
[root@nginx ~]# nginx -t
[root@nginx ~]# systemctl reload nginx
10.0.0.8 test.michaelxia.com
浏览器访问:http://test.michaelxia.com
[root@nginx ~]# rpm -ivh http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
[root@nginx ~]# yum install mysql-community-server -y
[root@nginx ~]# systemctl start mysqld
[root@nginx ~]# systemctl enable mysqld
[root@nginx ~]# mysql -uroot -p$(awk '/temporary password/{print $NF}' /var/log/mysqld.log)
数据库默认密码规则必须携带大小写字母、特殊符号,字符长度大于8否则会报错。
mysql> set password for root@localhost = password('123456');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
因此设定较为简单的密码时需要首先修改set global validate_password_policy参数值
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
1.此时密码限制已取消,判断密码的规则至基于密码的长度了,默认长度为8,由validate_password_length参数所决定
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 8 |
+----------------------------+
1 row in set (0.00 sec)
修改其最小值
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
此时密码长度最小值为4
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 4 |
+----------------------------+
1 row in set (0.00 sec)
mysql> set password for root@localhost = password('6256133');
Query OK, 0 rows affected, 1 warning (0.00 sec)
[root@nginx ~]# vim /code/test/mysqli.php
下载workpress数据包
[root@nginx ~]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
解压到站点目录
[root@nginx ~]# tar xf wordpress-4.9.4-zh_CN.tar.gz -C /code/test
修改权限
[root@nginx ~]# chown -R www.www /code/test/
创建workpress数据库
[root@http-server ~]# mysql -uroot -p123456
mysql> create database wordpress;
mysql> exit
浏览器访问域名进行workpress安装部署
前期站点部署与workpress一致:
浏览器访问域名对wecenter进行安装部署
站点配置文件必须安装管网要求修改
server {
listen 80;
server_name edu.michaelxia.com;
root /code/edusoho/web;
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/udisk {
internal;
root /code/edusoho/app/data/;
}
location ~ ^/(app|app_dev)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_param HTTP_X-Sendfile-Type X-Accel-Redirect;
fastcgi_param HTTP_X-Accel-Mapping /udisk=/code/edusoho/app/data/udisk;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
其他站点目录配置不变