Ubuntu 16.04 LTS下Chevereto免费版安装重定向异常求助
看起来你遇到的是Chevereto安装流程中URL重写规则未正确生效的典型问题——Chevereto的安装路由依赖Apache的mod_rewrite和根目录的.htaccess文件将/install路径转发到index.php处理,但目前你的环境没有正确完成这个转发,导致系统跳转到物理上不存在的/install目录,而直接访问app/install/installer.php会被拦截(这是Chevereto的安全设计,必须通过入口文件引导安装)。
下面是一步步的排查和解决步骤:
1. 再次确认mod_rewrite模块的启用状态
虽然你提到已经启用,但我们再做一次确认,避免模块未正确加载:
sudo a2enmod rewrite sudo systemctl restart apache2
执行完这两条命令后,模块应该已经完全生效。
2. 调整虚拟主机配置,允许.htaccess覆盖规则
Apache默认会限制目录下的.htaccess修改服务器配置,这会导致Chevereto的重写规则无法生效。编辑你的站点虚拟主机配置文件(通常位于/etc/apache2/sites-available/[你的站点名].conf):
找到对应Chevereto安装目录的<Directory>块,将AllowOverride的值改为All:
<Directory /var/www/chevereto> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory>
修改完成后,务必重启Apache让配置生效:
sudo systemctl restart apache2
3. 检查Chevereto根目录的.htaccess文件
确保Chevereto安装根目录下存在.htaccess文件,并且包含正确的重写规则。默认的.htaccess内容应该类似这样:
RewriteEngine On # If you have problems with the rewrite rules remove the "#" from the following RewriteBase line # You will also have to change the path to reflect the path to your Chevereto installation # RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L]
如果你的Chevereto不是安装在网站的根目录(比如是在/chevereto子路径下),需要取消注释RewriteBase这一行,并设置为你的实际路径,例如:RewriteBase /chevereto/。
4. 修复目录权限问题
确保Apache的运行用户(www-data)对Chevereto的所有目录和文件有足够的读写权限,否则可能影响重写规则的执行和安装流程:
sudo chown -R www-data:www-data /var/www/chevereto sudo chmod -R 755 /var/www/chevereto
5. 重新触发安装流程
完成以上所有步骤后,直接访问你的Chevereto站点根地址(比如http://your-domain.com),系统应该会自动通过index.php引导到正确的安装界面,而不会再跳转到不存在的/install目录了。
补充说明:Chevereto的app/install/installer.php文件本身带有访问限制,必须通过index.php的路由机制来访问,这是为了保证安装流程的安全性和完整性,所以只要重写规则正常工作,就不需要直接访问这个文件。
内容的提问来源于stack exchange,提问作者plaidshirt

