我有一个 laravel/php 项目,我想通过 apache2 将它部署在 ubuntu 上。 首先,我尝试部署默认示例 laravel 项目并且成功了。 但是,当我想使用自己的项目时,我无法进入 exampledomain.com/public。
当我点击 public 时出现 HTTP500 错误。
我该如何解决这个问题?
所有项目文件都在 /var/www/html 文件夹中。
我的 .conf 文件;
`
<Directory /var/www/html>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
`
我的 .htaccess 文件;
GNU nano 2.9.3 .htaccess
选项 -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
我也试过Nginx,根本不行。 我想在公共文件夹中启动 index.php 文件。但是,我无法让它发挥作用。
我在问题中看到您已经发布了
.htaccess
:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName reallywildgirls.uk
DocumentRoot /var/www/html/public
<Directory /var/www/html>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
这一行好像有问题:
AllowOverride None
请换成:
AllowOverride All
此外,请启用
rewrite
模块:
sudo a2enmod rewrite