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

NS-Sima's avatar

Laravel Deployment on Red Hat Enterprises Linux with https(apache)

I tried to deploy laravel app into linux distro Red Hat Enterprises to httpd (apache) server directory /var/www/html/ .

Versions

Red Hat Enterprises Version: 7.9

Laravel Version: 11.3

PHP Version: 8.2

Steps involved:1.Upload the project folder to server directory and config all .env2. Navigate to project folder, to public folder then moved index.php file into project root directory and edit it to locate vendor,booststrap,mantainance to start the app as shown on the code block

0 likes
15 replies
Snapey's avatar

no, no, no

Never do this. Change your web server config so that public is the document root

2 likes
NS-Sima's avatar

Hello @snapey There are other projects, if i change the web server all projects will be in a disaster.

NS-Sima's avatar

Hello @Tray2 i used this as the sample with .conf files created on httpd folder instead of apache2, and the project was hosted but the all other projects can not be accessed exept laravel app, i think this part is the issue as it overide all project folder directory

ServerAdmin [email protected] ServerName laravelapp.local DocumentRoot /var/www/html/LaravelApps/ProjectFolder/public

ErrorLog /var/www/html/LaravelApps/logs/error.log CustomLog /var/www/html/LaravelApps/logs/access.log combined

Include the laravelapp.conf into httpd.conf, tested config to okay, then restarted a server.

Qn: Can i do to overide only for the specified project only or any advise i can do ?

NS-Sima's avatar

Hello, I created a virtualhost on etc/httpd/conf.d/laravelapp.conf and edit to the below

<VirtualHost *:80> ServerName domain_name.com DocumentRoot /var/www/html/laravelapp/public

<Directory /var/www/html/laravelapp/public>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

ErrorLog /var/log/httpd/laravelapp_error.log
CustomLog /var/log/httpd/laravelapp_access.log combined

#Edited public/.htaccess to below <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] </IfModule>

Restarted the httpd.service php artisan config:clear

The project now successfully running but, the server having conflicts with codelIgnator projects, other non frameworks projects they're running good.

All other framework projects like codelIgnator now routes to my app, thats lead to have 404, not found.

Kindly assist to spot and advise what's wrong from here.

Snapey's avatar

I create all virtual hosts as individual .conf files in /apache2/sites-available

Each virtual host should have its own domain name or subdomain.

After creating the virtual host config, run a2ensite sitename.conf so that a symlink is created in the sites-enabled folder.

NS-Sima's avatar

Hello, I successfully managed to host the project by modifying the .htacess file in public folder into

What i understood from my case, The virtualhost created was overiding the server virtualhost leading to access one project only.

I can access the project with http://mydomain/projectFolderName/public

Thanks everyone for your support.

Snapey's avatar

@NS-Sima You will have problems with this setup, as well as issues accessing assets, exposing your logfiles and potentially your env file, you have also made it tricky to deploy.

NS-Sima's avatar

Hello @snapey Project is intentionally for internal LAN only, All of the process were to run the project on the real server. For assets they are handled by asset() and they're working fine.

Please or to participate in this conversation.