Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Wejdan's avatar

Deploy Laravel project to production server

Dear laracast comunity

i am in the phase of deploying my laravel project on dedicated server with LAMP environment:- Linux (centOS)/ Apache/ MariaDB/ PHP

I was able to put the project in the document root of web server installed the composer and generated key for laravel project, and do migration i changed the .env file to the new environment

and now i am facing two problems:- 1- when i route to server ip address as: xxx.xx.xx.xx

i get apache page "Testing 123.." and i need to type xxx.xx.xx.xx/ public in order to go to index

2- when i type the URL xxx.xx.xx.xx/public i can view the welocme page of laravel put if i want to login i need to type the URL like: xxx.xx.xx.xx/public/index.php/login although i have followed the instruction in Laravel regarding pretty URLs: https://laravel.com/docs/master/installation

which first enabling mode_rewrite for apache and second replace the .htaccess with the recommended one and it wont fix the problem i was able to fix the problem by going to httpd.conf file in server and change every

AllowOverride none

to

AllowOverride All

this fixed some URLs not all of them so far i am able to access welcome, login, register, and forget password pages other pages i get the below error:-

Whoops, looks like something went wrong.

i also set up the home directory of Apache config to var/www/hml/public

any help will be valuable thanks in advance

0 likes
3 replies
manniL's avatar

You definitely should set up the home directory of your Apache config to /path/to/your/laravel/project/public/. See this SO answer for more information and why it poses a security issue otherwise.

Example config (parts):

    DocumentRoot /var/www/html/path/to/your/laravel/project/public/

        <Directory /var/www/html/path/to/your/laravel/project/public/>
                Options -Indexes +FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
Wejdan's avatar
Wejdan
OP
Best Answer
Level 1

i solved the issue by doing the following:-

1- set document root to my/project/path/public

2- change httpd.conf file by altering every: AllowOverride none to AllowOverride All

3- pages that wont need database worked fine but pages that need retrieving results from database wont show up so i migrated all my tables then run website and it worked fine

1 like

Please or to participate in this conversation.