【发布时间】:2017-11-10 12:34:57
【问题描述】:
我知道有很多类似的帖子,但经过 3 小时的研究,我仍然找不到解决方案。希望有人能帮忙。
使用的技术:
- Apache/2.4.7 (Ubuntu)
- Laravel 5.4
- PHP 7.0
/etc/apache2/site-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin stanley@example.com
Servername example.com
DocumentRoot /var/www/html/example.com
<Directory />
Options +FollowSymLinks
#AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/example.com/>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/html/example.com/parcgilley/public">
Options Includes Indexes FollowSymLinks
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI +MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
.......
所以文档根目录位于 /var/www/html/example.com,而我的 laravel 站点位于 /var/www/html/example.com/parcgilley。我尝试配置 000-default.conf 以将我的站点指向 /var/www/html/example.com/parcgilley/public,但是当我转到 example.com/parcgilley 时,它显示“/parcgilley 的索引”。当我导航到 http://www.example.com/parcgilley/public/ 时,Chrome 会显示“此页面无法正常工作”。
这是我的 public/.htaccess 文件:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
这不是原始内容。我按照Laravel的说明操作,所以我用上面的代码替换了原点。
另外,我已经设置了 /parcgilley 项目根文件夹和存储文件夹的权限,但是没有用。
我不知道是否需要创建 .htaccess 文件以指向 /public 文件夹。但是我对apache配置了解不多。
任何见解将不胜感激。
已编辑:
我还使用 SSH 和 Git 将网站从本地机器推送到服务器,裸仓库位于 /var/repo/site.git。我不知道这是否与问题有关。
【问题讨论】:
标签: php apache .htaccess laravel-5