12.7 Nginx默认虚拟主机
1. 配置文件增加 include vhost/*.conf; 删除虚拟主机默认配置信息 //定义配置虚拟主机
2. 创建 vhost目录 和vhost.conf
3. 编辑vhost.conf
server
{
listen 80 default_server; // 有这个标记的就是默认虚拟主机
server_name aaa.com;
index index.html index.htm index.php;
root /data/wwwroot/default;
}
4. /usr/local/nginx/sbin/nginx -s reload
错误现象: php返回200 但页面空白 配置文件错误
server
{
listen 80 default_server;
server_name localhost;
index index.html index.htm index.php;
root /data/wwwroot/111;
location ~ \.php$ {
root html; //必须存在
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; //必须存在
}
}