By Irfan Rasool
I have a PHP web app running on production. Now I thought it is better to migrate on Digital Ocean. My code repository is on Gitlab. I know first I have to create a LAMP droplet. But what after that?
Can you please explain me what steps should I have to ensure a smooth transition?
Including my domain pointing and adding different environments like (testing, staging, production ) on single droplet.
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
You can start by setting up a LAMP Droplet as described below, or use the following 1-Click installation from the Marketplace:
Create a new Droplet on DigitalOcean: After logging into DigitalOcean, click on the “Create Droplet” button. Choose an Ubuntu base, and select your desired size. Once the Droplet is created, you’ll have access to its IP address.
Set up the LAMP stack:
ssh root@your_droplet_ipsudo apt-get updatesudo apt-get install apache2sudo apt-get install mysql-server. During the installation process, you will be asked to secure your MySQL installation.sudo apt-get install php libapache2-mod-php php-mysqlFor an indepth instructions on how to do this, follow this tutorial:
Set up Git:
sudo apt-get install gitgit config --global user.name "Your Name" and git config --global user.email "youremail@yourdomain.com"Clone your app:
cd /var/www/htmlgit clone your_gitlab_repo_urlSet up your .env file:
cd your_app_directorycp .env.example .envnano .env (update the settings to reflect your production environment)Install Composer dependencies:
composer install --no-dev --optimize-autoloaderSet up Apache:
sudo nano /etc/apache2/sites-available/your_app.conf<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/your_app_directory/public
ServerName your_domain
ServerAlias www.your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite your_app.confsudo service apache2 reloadDatabase migration:
mysql -u root -pCREATE DATABASE your_database;exit. Then, use the command: mysql -u username -p new_database < data-dump.sqlTest your application: Visit http://your_droplet_ip in your web browser.
Set up DNS: This will be done through your domain provider’s interface. Add an A record that points your domain to the droplet’s IP address.
SSL Certificate:
- Install Certbot: `sudo apt-get install certbot python3-certbot-apache`
- Get and install a certificate: `sudo certbot --apache`
Remember that these steps are an outline. Always ensure that you’re following the best practices for your application and server environment.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.