Your cart is currently empty!
Steps to deploy the laravel application on digital Ocean server
- Goto grabs droplet for your project:
- Create a Project on the DigitalOcean Platform and generate a public key
- Some Important commands run after login to droplets
- Create a New User inside droplets
- Compress your application and upload the file with FileZilla
- Edit Important files inside the server
- Check the group of processes and assign a new one
- Install Mysql Server
- Create a database user and database for your application
- Modify the environment file and clear the cache
- Some necessary commands for your application
Hi guys,
I am considering your application is ready for release, and you want to deploy your application on the server. In this article, we deploy the laravel application on Digital Ocean. Follow the steps to deploy the laravel application.
Goto grabs droplet for your project:
DigitalOceans is the best platform to host the laravel application. It supports managed Kubernetes clusters and “Droplets” features and Cloud firewalls, scales up and down, or migrates between Droplets. you can check out the plans. Click Here
Create a Project on the DigitalOcean Platform and generate a public key
Add a Project name with a type of project. choose a plan, CPU options, and data center region.
I am using an SSH login to access the droplet. Generate the public key for droplets with the below command:
ssh-keygen
/// Enter file name and passphrase
Add a public key to your droplet ssh login.
It takes time to create a droplet. I am using the Ubuntu operating system. We are making a config file inside the .ssh directory and inserting the below code inside this file.
Host laravel
HostName XXX.XXX.XXX.XXX
User root
IdentityFile ~/.ssh/[public key file name]
now you can log in to your droplets
ssh [public key file name]
Some Important commands run after login to droplets
Run the below command to update all packages.
sudo apt-get update
Add PPA to the droplet.
sudo add-apt-repository ppa:nginx/stable
sudo add-apt-repository ppa:ondrej/php
//install nginx server
sudo apt install -y nginx
//install php modules
sudo apt install -y php8.0-fpm php8.0-cli php8.0-mycrypt php8.0-gd php8.0-mysql php8.0-pgsql php8.0-imap php8.0-memcached php8.0-mnstring php8.0-xml php8.0-curl php8.0-bcmath php8.0-sqlite3 php8.0-xdebug php8.0-ctype php8.0-zip
Now you install composer inside your droplets.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --filename=composer --install-dir=/usr/bin
Create a New User inside droplets
It is best practice to create a user for your droplets. Run the below commands.
sudo adduser laravel
/// Add details of the user must add a strong password
usermod -aG sudo laravel
/// assign admin privilege to laravel user
Compress your application and upload the file with FileZilla
Go to the project folder and compress all files except vendor and npm_modules because the project compress size is too much. Now we are ready to upload your project on the droplet. After uploading the compressed file, extract it.
You use GitHub for project version control. If you add a GitHub link, it fetches all project files.
Edit Important files inside the server
You need to point out the project folder as the root folder of your project and some server configuration. Run the below command to modify the file.
vi /etc/nginx/sites-available/default
You can below what changes you need to look at in your default file.
After saving the file, you must check the syntax and reload the server.
sudo nginx -t
sudo service nginx reload
Check the group of processes and assign a new one
You can check PHP processes that run background.
ps aux | grep php
It will show the www-data user to process. Assign to a new user created above inside the www.conf file.
vi /etc/php/8.0/fpm/pool.d/www.conf
Run the service command to restart the php-fpm service.
sudo service php8.0-fpm restart
Install Mysql Server
For this application, we are installing MySQL for a database. Run the below command to install.
sudo apt install mysql-server -y
You can change your MySQL installation security options. Run the below command.
sudo mysql_secure_installation
Create a database user and database for your application
Login to the MySQL server through the command line and make a new database. See the below image.
Modify the environment file and clear the cache
You can open the .env file through the command line and change it.
Some necessary commands for your application
It will help you to run your applications. Do you want to make a custom command? Check out this article.
/// clear cache from application
php artisan cache:clear
/// clear config from application
php artisan config:clear
/// clean and store config data inside the application
php artisan config:cache
/// clear route from application
php artisan route:clear
/// looks for all the classes it needs to include again. It just regenerates the list of all Classes in the project.
composer dump-autoload
Now your application is ready to use on any browser. Check All operations of your application. I hope you have understood deploy the laravel application in the digital ocean.
Now your user will easily connect to your application. Do you want to check which mail tools are best for your application? Click Here. I hope that this post (Deploy the laravel application in the digital ocean.) has clarified how to integrate the Socialite package in laravel and load the drivers. If you have questions, please leave a comment and I will respond as soon as possible.
Thank you for reading this article. Please share this article with your friend circle. That’s it for the day. Stay Connected!
Cheers