vagrant虚拟机环境下Drupal新建站点重写地址问题的解决。网页404.

在本地vagrant虚拟机环境下新建或者恢复Drupal站点,总会出现网站页面404空白的现象。其原因是Drupal服务器地址重写原因,需要在服务器编辑一下nginx的站点配置文件.conf。使用命令进入

cd /etc/nginx/conf.d

ls

sudo vim wangzhan.conf

在里面加入一段代码:vim编辑器按i键进入编辑模式,编辑完成按Esc退出,并按:号,输入wq保存后退出。)

  location @rewrite {
                # You have 2 options here
                # For D7 and above:
                # Clean URLs are handled in drupal_environment_initialize().
                rewrite ^ /index.php;
                # For Drupal 6 and bwlow:
                # Some modules enforce no slash (/) at the end of the URL
                # Else this rewrite block wouldn't be needed (GlobalRedirect)
                #rewrite ^/(.*)$ /index.php?q=$1;
    }
然后在:

 location / {
        index  index.php index.html index.htm;
    }
添加一句代码:

 location / {
        index  index.php index.html index.htm;
        try_files $uri @rewrite;
    }

然后再 sudo service nginx reload 
就可以了。

提示:新网站目录最好在虚拟机环境内使用Linux命令建立

mkdir www
修改文件夹权限:

sudo chmod -R 755 phpadmin



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值