【问题标题】:Configure server to open public/index.php on '/' Laravel Project配置服务器以在 '/' Laravel Project 上打开 public/index.php
【发布时间】:2018-10-12 15:59:42
【问题描述】:

我目前正在第一次部署 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>

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

【问题讨论】:

  • 您收到的错误是什么?
  • 安娜珍妮的网址是什么?为了更好地解释规则,您可以使用htaccess.madewithlove.be 直接针对 URL 进行测试,请让我们知道完整的 URL。
  • 没有显示错误,但显示了服务器托管徽标。该网站是 www.badge-borduren.nl。
  • 将根目录设置为项目/公共文件夹而不是项目文件夹
  • 这是什么服务器。它是 LAMP 堆栈吗?您从哪里获得服务器(例如 Digital Ocean、Amazon webservice)?

标签: php laravel apache deployment


【解决方案1】:

我们不知道这是什么类型的服务器以及您从哪里获得它(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>

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

【讨论】:

    猜你喜欢
    • 2019-12-27
    • 2019-08-31
    • 2017-01-03
    • 2013-02-16
    • 2015-05-15
    • 2018-11-16
    • 2013-03-08
    • 2014-09-07
    • 2018-03-25
    相关资源
    最近更新 更多