在VPS上部署网站时,有时需要修改Nginx 或 Apache的默认网站目录(一般默认为default),以下为操作方式(在Centos7测试通过):
1、Nginx
cd /usr/local/nginx/conf
vi nginx.conf
查找server部分:
server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
root /home/wwwroot/default; //将这里default默认位置修改为你网站文件的目录,为了方便其他程序操作,还是建议将网页文件放在/home/wwwroot/****下
修改完毕后按Esc退出,保存:
:wq
最后重启lnmp生效:
lnmp restart
2、Apache
修改方式与Nginx基本一致
vi /usr/local/apache/conf/extra/httpd-vhosts.conf 将 DocumentRoot “/home/wwwroot/default” 及 Directory “/home/wwwroot/default” 两处中的 “/home/wwwroot/default” 修改为需要IP访问的域名,如 “/home/wwwroot/tonyvivi.com”。然后,重启lnmp生效。