在本地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