centos7.6从零开始编译nginx+mysql+php(五) 创建站点

先建立一个 lnmp 站点,路径是 /home/www/default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 创建目录 设置权限用户组
[root@localhost php-7.2.8]# mkdir -p /home/www/default
[root@localhost php-7.2.8]# chown -R www.www /home/www

# 创建一个phpinfo的测试文件
[root@localhost php-7.2.8]# cat >> /home/www/default/test.php << EOF
<?php
phpinfo();
EOF

# 创建一个 Nginx 配置文件放
[root@localhost php-7.2.8]# cd /usr/local/nginx/conf
[root@localhost conf]# sed -i '$i\include /usr/local/nginx/conf/conf.d/*;' nginx.conf
[root@localhost conf]# cat nginx.conf
[root@localhost conf]# mkdir conf.d
[root@localhost conf]# cd conf.d/

# 创建test.com.conf文件并写入以下内容
# listen 端口号
# server_name 指向的IP或者域名
# root 网站目录
[root@localhost conf]# cat >> test.com.conf <<EOF
server {
listen 80;
server_name 192.168.0.10;
root /home/www/default;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PHP_VALUE open_basedir=\$document_root:/tmp/:/proc/;
include fastcgi_params;
}
}
EOF

# 重启nginx和php
[root@localhost conf.d]# systemctl reload nginx
[root@localhost conf.d]# systemctl reload php-fpm

访问 http://192.168.0.10/test.php

phpinfo页面正常运行,安装完成。

这次打算用这个环境学习下基础的Linux使用,然后开始swoole的搭建和使用。


评论区