[英]Laravel Public folder accessible on LAMP server
I am in dire need of help with setting up my laravel project on a LAMP server. 我非常需要在LAMP服务器上设置laravel项目的帮助。 So far I have tested my "Pretty URLs" on my localhost xampp server with no problems.
到目前为止,我已经在我的本地主机xampp服务器上测试了“ Pretty URL”,没有问题。 Now that I am trying to set it up on an actual LAMP server I am running into issues
现在,我试图在实际的LAMP服务器上进行设置,但遇到了问题
So far I have installed the LAMP services (Ubuntu, Apache2, MYSQL, PHP5 (with curl and mcrypt)). 到目前为止,我已经安装了LAMP服务(Ubuntu,Apache2,MYSQL,PHP5(带有curl和mcrypt))。 Currently I have my laravel project in my home directory with a symlink to the public folder in my /var/www/html folder like so... project , symlink .
目前,我有我的laravel项目在我的主目录用符号链接到公用文件夹在我的/ var / www / html等文件夹,像这样...... 项目 , 符号链接 。
I have changed my /etc/apache2/apache2.conf with following config 我已经使用以下配置更改了/etc/apache2/apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I then used the command, sudo a2enmod rewrite
and edited my .htaccess file as per the instructions in the laravel docs. 然后,我按照laravel文档中的说明使用命令
sudo a2enmod rewrite
并编辑了.htaccess文件。
Finally, I restarted my apache service: sudo service apache2 restart
, and when I attempt to go to "mydomain.com/public" I receive a 403 forbidden error. 最后,我重新启动了apache服务:
sudo service apache2 restart
,当我尝试转到“ mydomain.com/public”时,我收到403禁止错误。
Is there anyone out there who can help me? 有没有人可以帮助我?
Regarding Apache
configuration, it seems to be fine. 关于
Apache
配置,这似乎很好。 What I prefer is to disable Indexes (to prevent the directory listing) and MultiViews (to prevent implicit filename pattern match). 我更喜欢禁用索引(以防止目录列表)和多视图(以防止隐式文件名模式匹配)。
<Directory /var/www/html>
Options +FollowSymLinks -MultiViews -Indexes
AllowOverride All
Require all granted
#some general directives could be handy here also
<FilesMatch "\.(png|jp?g|gif|ico|mp4|wmv|mov|mpeg|css|map|woff?|eot|svg|ttf|js|json|pdf|csv)">
ExpiresActive on
ExpiresDefault "access plus 2 weeks"
</FilesMatch>
</Directory>
The problem seems to be permission related. 问题似乎与许可有关。 By default the
Apache
runs as www-data:www-data
. 默认情况下,
Apache
作为www-data:www-data
。 This could be changed in envvars
(changes should be followed by Apache
restart) or during provided as compile time option. 可以在
envvars
进行更改(更改后应重新启动Apache
)或在编译时选项中envvars
更改。 The /etc/apache2/envvars
/etc/apache2/envvars
...
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
...
However, a nicer way would be 但是,更好的方法是
/var/www/html
to www-data
with sudo chown :www-data /var/www/html
sudo chown :www-data /var/www/html
将/var/www/html
组更改为www-data
sudo chown :www-data /var/www/html
/var/www/html
to 2770
with sudo chmod 2770 /var/www/html
. sudo chmod 2770 /var/www/html
将/var/www/html
的模式更改为2770
。 Since Apache
needs execute permission to access the directory. Apache
需要执行权限才能访问目录。 Apply this command to other directories recursively 2660
for safety measures 2660
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.