下面用到的包全在这里
链接:https://pan.baidu.com/s/1aYdKzZY3m3jEnC8bWK3OwA
提取码:d0am
1.安装nginx
配置官方源
https://www.cnblogs.com/chenlifan/p/13533345.html
2.安装php (7版本)
1)安装
1 [root@web01 ~]# mkdir /package 2 [root@web01 ~]# cd /package/ 3 [root@web01 /package]# rz php.tar.gz 4 [root@web01 /package]# tar xf php.tar.gz
1 [root@web01 /package]# yum localinstall -y *.rpm
2)配置php
[root@web01 /package]# vim /etc/php-fpm.d/www.conf user = www group = www
3) 启动服务
1 [root@web01 /package]# systemctl start php-fpm 2 [root@web01 /package]# systemctl enable php-fpm
4) 验证启动
[root@web01 /package]# netstat -lntp
3.搭建交作业页面
1)配置nginx
[root@web01 /package]# vim /etc/nginx/conf.d/default.conf server { listen 80; server_name www.zuoye.com; location / { root /code/zuoye; index index.html; } }
2)创建站点目录
[root@web01 /package]# mkdir /code/zuoye -p
3)上传代码
1 [root@web01 /package]# cd /code/zuoye/ 2 [root@web01 /code/zuoye]# rz kaoshi.zip 3 [root@web01 /code/zuoye]# unzip kaoshi.zip 4 [root@web01 /code/zuoye]# chown -R www.www /code/
4)修改交作业代码
[root@web01 /code/zuoye]# vim upload_file.php $wen="/code/zuoye/upload";
5) 访问测试
[root@web01 /code/zuoye]# systemctl restart nginx
drivers
10.0.0.7 www.zuoye.com
4.关联nginx和PHP
1) 配置
[root@web01 /code/zuoye]# vim /etc/nginx/conf.d/default.conf server { listen 80; server_name www.zuoye.com; location / { root /code/zuoye; index index.html; } location ~* .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /code/zuoye/$fastcgi_script_name; include fastcgi_params; } }
3)仿问页面测试
[root@web01 /code/zuoye]# systemctl restart nginx
[root@web01 /code/zuoye]# vim /etc/nginx/nginx.conf
client_max_body_size 100M;
[root@web01 /code/zuoye]# systemctl restart nginx
[root@web01 /code/zuoye]# vim /etc/php.ini
post_max_size = 100M
upload_max_filesize = 100M
[root@web01 /code/zuoye]# systemctl restart php-fpm