How to upload local Laravel project to server ?

Created at 13-Mar-2024 , By samar

To upload the laravel local project to server you have to first check the node_modules directory and dist directory in public folder and vendor directory exist or not. Before uploading files to server check the all important files (node_modules, vendor, public/dist, vendor/autoload.php) which is required to run application properly.

If thery are not available then please run composer install command to generate the vendor folder, npm install and npm run build to generate the node_modules and public/dist folder and also run composer dump-autoload if autoload.php file is not available in vendor directory.

Create database on server and import data from local development environment.

Compress local laravel project to zip file and upload to server (public_html)

Make changes for database and others configuration details to your .env file

APP_URL=http://domain.com


DB_DATABASE=database_name
DB_USERNAME=database_username
DB_PASSWORD=database_password

Create a .htaccess file on project root directory and place below code in it.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization MemberHeader
    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]

    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L,QSA]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Now you can visit you website. Hope it works for you.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.