use*_*181 53 apache ubuntu laravel laravel-4
我有一个Ubuntu 14.04内核.我在这台服务器上安装了我的Laravel应用程序.安装后,我尝试将根目录设置为public.
sudo nano /etc/apache2/sites-available/000-default.conf
Run Code Online (Sandbox Code Playgroud)
我在文件中只有这些选项
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Run Code Online (Sandbox Code Playgroud)
我已将Document根目录更改为
DocumentRoot /var/www/html/public/
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试访问我的Laravel应用程序时,通过123.xxx.xxx.xxx/它显示主页并且运行良好.它也获得了所有的GET变量.例如:123.xxx.xxx.xxx?type=wefwef
但是当我转到其他链接时,123.xxx.xxx.xxx/login它会给我一个错误
Not Found
The requested URL /login/ was not found on this server.
Apache/2.4.7 (Ubuntu) Server at 104.236.234.85 Port 80
Run Code Online (Sandbox Code Playgroud)
我的routes.php在localhost上运行良好.但不是在这台服务器上.请帮我.
luk*_*ter 116
这看起来像你必须.htaccess通过添加到您的vhost 启用:
<Directory /var/www/html/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,请确保已启用mod_rewrite.
不要忘记在进行更改后重启apache!(service apache2 restart)
小智 49
我通过执行以下操作解决了:检查apache中是否存在名为rewrite.load的模块:
cd /etc/apache2/mods-enabled/
Run Code Online (Sandbox Code Playgroud)
如果它不存在,请执行以下摘录:
sudo a2enmod rewrite
Run Code Online (Sandbox Code Playgroud)
否则,请更改Apache配置文件以合并使用"友好URL".
sudo nano /etc/apache2/apache2.conf
Run Code Online (Sandbox Code Playgroud)
在编辑器中找到以下代码:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
改成:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
之后通过以下方式重启Apache服务器:
sudo /etc/init.d/apache2 restart
Run Code Online (Sandbox Code Playgroud)
Mat*_*Raj 21
首先启用a2enmod rewrite
下一次重启apache
/etc/init.d/apache2 restart
Run Code Online (Sandbox Code Playgroud)
小智 9
对于 vagrant box 内的 Ubunutu 18.04 ...这对我有帮助
确保 www-data 有权访问 .htaccess 文件
sudo chown www-data.www-data .htaccess
编辑 apache2 conf 以允许符号链接等
sudo nano /etc/apache2/apache2.conf
将其添加到文件中
sudo chown www-data.www-data .htaccess
重新启动您的 apache2 服务器
sudo service apache2 restartRun Code Online (Sandbox Code Playgroud)我希望这可以帮助别人。
或者,您可以替换 .htaccess 文件中的所有内容
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Run Code Online (Sandbox Code Playgroud)
请参阅此处的文档。 https://laravel.com/docs/5.8/installation#web-server-configuration
| 归档时间: |
|
| 查看次数: |
102783 次 |
| 最近记录: |