To run laravel project on apache server like xampp you DO NOT need to change server.php;
There are two options to run laravel project:
A. Move contents of public folder:
- Move all contents of public folder to root of project.
- Change two lines in index.php in project root like below
//index.php
.
.
.
require __DIR__.'/vendor/autoload.php';
.
.
.
$app = require_once __DIR__.'/bootstrap/app.php';
.
.
.
warning: In this method all files must be protected. My suggestion is to change .htaccess
- change .htaccess in root of project like below:
<IfModule mod_rewrite.c>
# Deny access to .htaccess
<Files .htaccess>
Order allow,deny
Deny from all
</Files>
<Files .env>
Order allow,deny
Deny from all
</Files>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/path/to/public_html
</IfModule>
B: Move public folder
- Move your public folder to public_html and other files in a folder aligned with public_html with your-project-name (in xampp you can put it prev folder of htdocs)
2.change index.php like below:
//index.php
.
.
.
require __DIR__.'../your-project-name/vendor/autoload.php';
// in xampp: require __DIR__.'../../your-project-name/vendor/autoload.php';
.
.
.
$app = require_once __DIR__.'../your-project-name/bootstrap/app.php';
// in xampp: $app = require_once __DIR__.'../../your-project-name/bootstrap/app.php';
.
.
.