简体   繁体   English

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

[英]Configure server to open public/index.php on '/' Laravel Project

I'm currently working on deploying a laravel project for the first time. 我目前正在首次部署laravel项目。 I have succeeded in installing a laravel project on my server but unfortunately, when going to the website no laravel page is shown. 我已经成功在服务器上安装了laravel项目,但是不幸的是,当转到网站时,没有显示laravel页面。 My .htaccess file in the root directory: 我的.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>

Could someone please help me with this issue? 有人可以帮我解决这个问题吗?

We do not know about what kind of server this is and where you got it (AWS, Digital Ocean). 我们不知道这是什么类型的服务器以及您在哪里购买的(AWS,Digital Ocean)。

Generally you have to move to this directory in your server: 通常,您必须移至服务器中的以下目录:

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

Now you open that file using the touch, vi or nano: 现在,您可以使用vi或nano触摸来打开该文件:

sudo nano laravel.conf

The file should have a similiar content to this one: 该文件应与此内容类似:

<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>

Now you need to change to location to your app/public location like I did in the sample config file. 现在,您需要像在示例配置文件中一样,将位置更改为您的应用/公共位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM