lnmp 搭建虚拟主机域名了

接上一篇文章centos7搭建lnmp (php7 + mysql5.7 +nginx1.8)

配置好了当然到配置虚拟主机域名了

  1. 首先先在 /etc/nginx (在安装目录中),新建一个vhosts目录   
mkdir vhosts

 

    2. 在vhosts新建一个文件(名称建议是你的域名.conf),并写入

server {
    listen 80;
    server_name xxx.com;     //这是网站域名
    access_log /var/log/nginx/access_domain1.log main;  //这是记录的日志,养成看日志的习惯
    root /www/php/blog;               //这是网站根目录

    location / {
        index index.php index.html index.htm;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php,phpinfo.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

接着在 /etc/nginx/nginx.conf 中的http节点中,建议是server节点前加入引用


最后运行

nginx -s reload

然后运行浏览器即可看到效果


建议:如果出错了就找到你的日志文件,查看错误原因,要养成查看错误日志的习惯

猜你喜欢

转载自blog.csdn.net/luo1324574369/article/details/80566545
今日推荐