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

narachamus's avatar

Deploy Laravel 9 project in a normal hosting manually

Good morning. I have finished my project in Laravel 9, and I have many doubts to deploy it in production environment. I have watched many tutorials and videos, each one explaining it differently, and none of them fits what I want. I don't use Forge, nor Vapor, nor Nginx, nor CPanel, I just want to upload the Laravel website to a normal apache hosting. What to do with the .env file? Currently it has all the project settings: email, database, app key, google key.... Git ignores the file with gitignore, is it supposed to copy it manually, create a new one on the server, or move it to another folder? What files and folders should I copy to the server, do I have to load libraries and components with composer from terminal?

I appreciate any help, video or reference site that can guide me. Regards

0 likes
4 replies
Tray2's avatar

If the Apache server is properly set up with the document root set to /public , then you don't need to do anything. Just make sure that the env isn't accessible.

If you don't have the /public document root, then you need to handle with a htaccess file and redirect all requests to /public.

I have shared a working htaccess here several times.

1 like
narachamus's avatar

@Tray2 thanx for the answer. I have a problem. It is a shared hosting, so I don't have access to SSH terminal. In the hosting I have the old version of the web. Because I want both to be running, I have created a subdomain called test.mydomain.com, in a root folder called "v2", and I have uploaded the Laravel project there.

The problem is that when I open test.mydomain.com in the browser, I get a blank page. It does not give errors of any kind. Do I need an htaccess ? My .env right now is:

APP_NAME=testlaravel
APP_ENV=production 
APP_KEY=
APP_DEBUG=false
APP_URL=http://test.mydomain.com
Tray2's avatar

@narachamus A blank page used to mean that you don't have write access to the storage directory, but in your case I don't think that that is the problem. Yes you might need a proper htaccess to handle you issues.

I use something like this in my shared hosting.

#Rewrite everything to subfolder 
RewriteEngine On 
RewriteCond %{REQUEST_URI} !^/public 
Rewriterule ^(.*)$ public/ [L]
Snapey's avatar

Have a laracasts subscription? https://laracasts.com/series/servers-for-laravel/episodes/1

Yes, you will create a .env file on the server with production settings

You should ideally deploy the code from a repo such as github or bitbucket

And run composer on the server to pull in all the vendor libraries.

I you are compiling your front end assets you may also need node and npm in order to compile on the server. I don't, I compile locally, commit the assets to version control and pull them in on the server.

Under Apache create a host (or virtual host) that points to the laravel public folder.

You don't want forge or cpanel so I assume you are familiar with setting all this up and setting the correct file system permissions etc?

1 like

Please or to participate in this conversation.