PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 28, 2022

[FIXED] Nothing accessible in my Laravel project except the home page

 February 28, 2022     apache2.4, lamp, laravel     No comments   

Issue

been searching for the past 3 days about configuring laravel 5.4 on my linux mint 18.2 system running apache 2.4 . when apache server starts and i manually type in localhost in the browser,it does show up the default home page of laravel , but when i try to access it through live preview in brackets (live preview base url : http://localhost as my laravel project pro lies in /var/www/html/)but it throws internal server error corresponding to the errors in my apache configuration.So here i put forward my .htaccess file , 000-default.conf file in sites-enabled directory of apache2 and apache2.conf files : One important thing : i got my project folder pro under /var/www/html/

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>

thank you before hand!


Solution

Your all routes would be available after index.php, i mean if your route's url is abc, then it will be open as http://localhost/index.php/abc. Now you don't need to change anything in .htacesss file.

Go to your project root and give the read write execute permissions, so that laravel will able to cache the file inside bootstrap/cache directory and able to create your logs file inside storage/logs directory.

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

If your project didn't run after that also, then sometimes you need to give this permission also.

sudo chmod -R 777 vendor/ storage/

Run these three commands after that

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

your route should be served after localhost.

Hope this will help :)



Answered By - Vikash
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing