Navigate to Public HTML: Start by navigating to the public HTML folder on your server where you want to deploy your Laravel project:
cd /var/www/html
Clone Your Project: Clone your Laravel project repository into the current directory. A new directory with your project name will be automatically created:
git clone url_here
Configure .env File: Copy the .env.example
file to .env
and update the necessary environment variables such as database credentials and app key:
cp .env.example .env
nano .env
Set Directory Permissions: Set appropriate permissions for directories that require both reading and writing:
sudo chmod -R 755 directory
sudo chmod -R o+w directory/storage
Install Composer Dependencies: Install the PHP dependencies required by your Laravel project using Composer:
composer install
Set Cache Permissions: Set permissions for the bootstrap cache directory:
sudo chmod -R 777 bootstrap/cache
Install Required PHP Extensions (Optional): If your project relies on specific PHP extensions like curl, install them using the package manager:
sudo apt-get install php-curl
Restart the Web Server: Restart Apache or your web server to apply the changes:
sudo service apache2 restart
By following these steps, you’ll be able to set up your cloned Laravel project on a Linux server effectively while ensuring proper permissions and dependencies are in place. Make sure to replace url_here
with the actual URL of your project repository.