代码之家  ›  专栏  ›  技术社区  ›  acaman

除了主页之外,我的Laravel项目中没有其他内容可访问

  •  2
  • acaman  · 技术社区  · 7 年前

    在过去的3天里,我一直在搜索如何在运行apache 2.4的linux mint 18.2系统上配置laravel 5.4。当apache服务器启动并且我在浏览器中手动键入localhost时,它确实会显示laravel的默认主页,但当我尝试通过括号中的live preview访问它时(live preview基本url: http://localhost 由于我的laravel project pro位于/var/www/html/)中,但它引发了与apache配置中的错误相对应的内部服务器错误。所以在这里我提出了我的建议。htaccess文件,000默认值。apache2和apache2的sites enabled目录中的conf文件。配置文件: 一件重要的事:我在/var/www/html下找到了我的项目文件夹pro/

    1. 000-default.conf(sites-enabled)
    
    
    <VirtualHost *:80>
    
        ServerName localhost
    
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pro/public
    
        <Directory /var/www/html/pro/public>
        Options Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>
    
    
     2. apache2.conf
    
    
    
     Mutex file:${APACHE_LOCK_DIR} default
       PidFile ${APACHE_PID_FILE}
       Timeout 300
       KeepAlive On
       MaxKeepAliveRequests 100
       KeepAliveTimeout 5
       User ${APACHE_RUN_USER}
       Group ${APACHE_RUN_GROUP}
       HostnameLookups Off
    
       ErrorLog ${APACHE_LOG_DIR}/error.log
    
       LogLevel warn
    
       IncludeOptional mods-enabled/*.load
       IncludeOptional mods-enabled/*.conf
    
       Include ports.conf
    
       <Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
       </Directory>
    
       <Directory /usr/share>
        AllowOverride None
        Require all granted
       </Directory>
    
       <Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
       </Directory>
    
       AccessFileName .htaccess
    
       <FilesMatch "^\.ht">
        Require all denied
       </FilesMatch>
    
       IncludeOptional conf-enabled/*.conf
       IncludeOptional sites-enabled/*.conf
       Include /etc/phpmyadmin/apache.conf
    
       3 .htaccess (/var/www/html/pro/public/.htaccess)
    
    
    
     <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
        RewriteEngine On
        RewriteBase /var/www/html/pro/public/
    
        # 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]
    
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    </IfModule>
    

    谢谢大家!

    2 回复  |  直到 7 年前
        1
  •  2
  •   Vikash    7 年前

    索引后,您的所有路线都将可用。php,我的意思是如果你的路线的url是abc,那么它将作为 http://localhost/index.php/abc . 现在你不需要在中更改任何内容。Htacess文件。

    转到项目根目录并授予读写执行权限,以便laravel能够在其中缓存文件 引导/缓存 目录,并能够在其中创建日志文件 存储/日志 目录

    sudo chmod -R 777 bootstrap/cache
    sudo chmod -R 777 storage/logs
    

    如果您的项目在此之后也没有运行,那么有时您也需要授予此权限。

    sudo chmod -R 777 vendor/ storage/
    

    然后运行这三个命令

    sudo a2ensite 000-default.conf
    sudo a2enmod rewrite
    sudo service apache2 restart
    

    您的路线应该在localhost之后提供。

    希望这会有所帮助:)

        2
  •  0
  •   KalyanLahkar    7 年前

    尝试在laravel中为您的存储和引导文件夹授予读/写权限。如果可以,还可以设置虚拟主机。参考 here .