vim httpd.conf
#打开注释
Include conf/extra/httpd-vhosts.conf
cd extra vim httpd-vhosts.conf
#添加如下代码(把test改为你真正的域名)
<VirtualHost *:9090> DocumentRoot "/phpstudy/www/test" ServerName test.com ServerAlias test.com </VirtualHost> <VirtualHost *:9090> DocumentRoot "/phpstudy/www/test" ServerName www.test.com ServerAlias www.test.com </VirtualHost>
然后重启php
修改nginx配置
vim /etc/nginx/conf.d/test.com.conf
server{
    listen 80;
    server_name test.com www.test.com;
    location / {
        proxy_pass http://test.com:9090/;
        proxy_redirect  off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;a
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_intercept_errors on;
    }
    error_page 404 = /404.html;
        #error_page 404 /404.html;
                #location = /40x.html {
        #}
    #error_page 500 502 503 504 /50x.html;
        #location = /50x.html {
    #}
}最好把500错误注释掉,否则nginx直接拦截,看不到具体报错
重启nginx
service nginx restart
