我的vps是按照这个安装起来的https://lnmp.org/install.html
能够sftp访问
1、按照这个教程,添加一个虚拟主机https://lnmp.org/faq/lnmp-vhost-add-howto.html
2、完成后,会生成一个文件 /usr/local/nginx/conf/vhost/域名.conf
3、修改这个文件就可以了,比如我的
server
{
listen 端口1;
#listen [::]:80;
server_name IP地址;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/网站项目文件夹;
include none.conf;
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log off;
}
server
{
listen 端口2;
#listen [::]:80;
server_name IP地址;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/网站项目文件夹;
include none.conf;
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log off;
}
执行命令行:/etc/init.d/nginx restart 重新启动一下nginx
注意:我是在chrome浏览器下面访问的,由于或许缓存原因,我访问
http://ip地址/端口1
http://ip地址/端口2
的时候,老是会跳到http://ip地址/所在网站中,清理缓存就没事了。