在服务器(本地和实时)中托管 laravel 项目时出现问题

An issue while hosting laravel project in server(local and live)

我想在专用服务器(aws,ubuntu 14.04)中托管一个 laravel 项目。

所以我把项目放在了/var/www/html。当我转到 11.111.11.111/projectFolder/public 时,会显示默认的欢迎页面,

但是当我移动到 11.111.11.111/projectFolder/public/login 时,我收到一个错误 - 页面未找到,有趣的是 11.111.11.111/projectFolder/public/index.php/login,登录页面显示但样式和 jss 文件丢失。

Failed to load resource: the server responded with a status of 404 (Not Found) http://11.111.11.111/js/app.js Failed to load resource: the server responded with a status of 404 (Not Found)

所有这些 cssjs 文件都存在于 laravel 应用程序的 public 文件夹中。

当我 运行 使用 php artisan serve

进行项目时,这些效果非常好

.htaccess文件如下,

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

我只想更改 .htaccess 文件,所以当我输入 11.111.11.111 时,应用程序显示为 运行 正常。

如果您想使用 http://11.111.11.111 直接查看您的项目,您必须更改 httpd.conf 文件中的 DocumentRoot 设置。

在您的 /etc/apache2/sites-available/000-default.conf 文件中,将目录根更改为:

DocumentRoot /var/www/html/projectFolder/public