Steps to create a new WordPress blog or Transfer existing WordPress blog to Digital Ocean droplet
Overall down time needed around 2 hours. Around 1.5 hours for DNS or nameserver propogation. 30 minutes for installation and configuration of the site. Your new blog or website would be up in digital ocean in around 2 hours.
Any restoration of files and DB can be done while the site is back up and running.
pre – requisite: Point domain name to Digital ocean nameserver:
1. Create a droplet in Digital ocean
select location and system configurations
2. Add domain to dashboard
point the domain to the new droplet, add A name and CNAME records
3. Install Apache, PHP and MYSQL using below commands
follow the below steps
sudo apt update
sudo apt install apache2
sudo ufw app list
sudo ufw allow in “Apache”
sudo ufw status
sudo apt install mysql-server
sudo mysql_secure_installation
sudo mysql
exit
sudo apt install php libapache2-mod-php php-mysql
php -v
sudo mkdir /var/www/jaytest.xyz
sudo chown -R $USER:$USER /var/www/jaytest.xyz
sudo nano /etc/apache2/sites-available/jaytest.xyz.conf
<VirtualHost *:80>
ServerName jaytest.xyz
ServerAlias www.jaytest.xyz
ServerAdmin webmaster@localhost
DocumentRoot /var/www/jaytest.xyz
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite jaytest.xyz
sudo a2dissite 000-default
sudo apache2ctl configtest
sudo systemctl reload apache2
nano /var/www/jaytest.xyz/index.html
<html>
<head>
<title>Some lorem ipsum title here</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is the landing page of <strong>your_domain</strong>.</p>
</body>
</html>
sudo mysql
CREATE DATABASE blog1;
CREATE USER ‘blog_user1’@’%’ IDENTIFIED WITH mysql_native_password BY ‘$BlogR%575’;
GRANT ALL ON *.* TO ‘blog_user1’@’%’;
exit
check as new user
mysql -u blog_user1 -p (Command to login as the newly created user. You will be prompted with password option. After checking the username password is working, use exit command to come out of mysql)
4. Install PHPmyadmin
moving on to
sudo apt update
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
Warning: When the prompt appears, “apache2” is highlighted, but not selected. If you do not hit SPACE to select Apache, the installer will not move the necessary files during installation. Hit SPACE, TAB, and then ENTER to select Apache.
sudo apt install phpmyadmin
sudo apt install php8.1-mbstring
sudo systemctl restart apache2
———————————–
To disable error and warnings
———————————–
go to config.inc.php at /etc/phpmyadmin
add the below config option in the file and save the file to the server
$cfg[‘SendErrorReports’] = ‘never’;
sudo systemctl restart apache2
———————————–
To change login url for Phpmyadmin
———————————–
open /etc/phpmyadmin/apache.conf via FTP in notepad
Comment the existing Alias and then add a new one as follows:
# Alias /phpmyadmin /usr/share/phpmyadmin
Alias /secretlinktophpmyadmin /usr/share/phpmyadmin
Save the file and upload to server.
echo “Include /etc/phpmyadmin/apache.conf” >> /etc/apache2/apache2.conf
systemctl restart apache2
5. Uploading wordpress and unzipping files
sudo apt install zip
cd /var/www/jaytest.xyz
sudo unzip wordpress.zip -d “/var/www/jaytest.xyz”
mv wordpress/* .
rm -r wordpress
cd /var/www/
chown -R www-data:www-data jaytest.xyz
chmod 755 -R jaytest.xyz
6. Install certificate
Make sure to install SSL only after the domain name has completely propogated to Digital Ocean (that is: you have changed the name servers atleast 90 minutes before)
certbot –apache -d jaytest.xyz -d www.jaytest.xyz
Now the installation and configuration of the new domain in Digital ocean droplet is completed. SSL is now configured as well. You can perform the WordPress installation by using the domain name (blog url) in the browser and giving the database credentials.
Note:
If you use custom link structures / permalinks for your blog, then you need to add this entry in 2 config files, your_domain.conf and your_domain-le-ssl.conf. Both are present in this location. Once the entries are added you need to restart apache once systemctl restart apache2
Config files location: /etc/apache2/sites-available
your_domain.conf
<VirtualHost *:80>
ServerName your_domain
ServerAlias www.your_domain
ServerAdmin webmaster@localhost
DocumentRoot /var/www/your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/your_domain>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.your_domain [OR]
RewriteCond %{SERVER_NAME} =your_domain
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
your_domain-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName your_domain
ServerAlias www.your_domain
ServerAdmin webmaster@localhost
DocumentRoot /var/www/your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/your_domain>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/your_domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your_domain/privkey.pem
</VirtualHost>
</IfModule>
Congrats!
You should be all good to go now.
Main reference links:
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-20-04
Additional reference for any errors:
https://stackoverflow.com/questions/24588897/phpmyadmin-config-inc-php-configuration
https://askubuntu.com/questions/1393439/set-phpmyadmin-to-never-ask-about-deprecation-warnings-on-ubuntu
https://stackoverflow.com/questions/52913263/how-to-hide-lacking-phpmyadmin-warnings