配置服务器以在'/'Laravel Project上打开public / index.php

时间:2018-05-02 13:54:58

标签: php laravel apache deployment

我目前正在努力首次部署laravel项目。我已成功在我的服务器上安装了一个laravel项目,但不幸的是,当访问该网站时,没有显示laravel页面。根目录中的.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 ^(.*)/$ /$1 [L,R=301]

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

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?mydomain.nl$
    RewriteRule ^(/)?$ public [L]
</IfModule>

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

我们不知道这是什么类型的服务器以及您获得它的位置(AWS,Digital Ocean)。

通常,您必须移至服务器中的此目录:

/etc/apache2/sites-enabled/laravel.conf

现在使用touch,vi或nano打开该文件:

sudo nano laravel.conf

该文件应具有与此类似的内容:

<VirtualHost *:80>.
    ServerName app.com // your server name
    ServerAdmin webmaster@localhost
    # Your Custom folder 
    DocumentRoot /dir/dir/dir/app/public/ // here you need to add your location
    <Directory /dir/dir/dir/app/public/>  // here you need to add your location
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log
</VirtualHost>

现在您需要更改到应用/公共位置的位置,就像我在示例配置文件中所做的那样。

相关问题