Nginx在已有网站的情况下新建第二个网站
首先打开Nginx的配置文件nginx.conf
复制一份原来的server配置,添加在原配置的下方(下面的配置添加了https,需要证书才能访问)
server {
listen 80;
server_name 你的域名;
return 301 https://你的域名$request_uri;
}
server {
listen 443 ssl http2 default_server;
ssl on;
ssl_certificate 你的证书路径;
ssl_certificate_key 你的证书秘钥路径;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
server_name 你的域名;
index index.html index.htm index.php;
root 你的新网站根目录;
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log 你的日志路径;
}
之后保存,重启Nginx服务
service nginx restart
检查一下有没有生效?