Run your WordPress website on UBUNTU Server using VM on cloud platform like Google Cloud , AWS or Azure.




UPDATE THE SYSTEM

The first step is to install all the necessary Updates and Upgrades on your system. It’s a good idea to update and upgrade your Ubuntu System.

sudo apt-get update && sudo apt-get upgrade -y






Install MYSQL, PHP, and APACHE

The next step is to install Apache, PHP, and Mysql.

sudo apt install apache2 ghostscript libapache2-mod-php mysql-server 
php php-bcmath php-curl php-imagick php-intl php-json php-mbstring 
php-mysql php-xml nano curl -y







Download & Install WordPress

In the next step, we will download and install WordPress, For this, we need to first create a directory “/srv/www” using the command “sudo mkdir -p /srv/www” This directory will be used to download the WordPress and then we will install WordPress on this location.

next, we will Download and extract the WordPress files, in the last command, we will create a WordPress.conf file manually

sudo mkdir -p /srv/www sudo chown www-data: /srv/www curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www sudo touch /etc/apache2/sites-available/wordpress.conf




Enable WordPress Website

Run the below commands to Disable the default website  “000-default” and enable the WordPress website.

sudo a2ensite wordpress sudo a2enmod rewrite sudo a2dissite 000-default sudo service apache2 reload




Edit the Config File “wordpress.conf”

Before moving any further we need to edit our Config file, For this instance, our config file is placed at this location “/etc/apache2/sites-available/“, In order to accomplish this you first need to change the directory by running the below commands.

The “cd” command will change our current directory and point to “/etc/apache2/sites-available/“, The echo command will be used to insert the strings into our WordPress.config file.

cd /etc/apache2/sites-available/ echo '' | sudo tee wordpress.conf echo '<Directory /srv/www/wordpress>' | sudo tee -a wordpress.conf echo ' Options Indexes FollowSymLinks' | sudo tee -a wordpress.conf echo ' AllowOverride All' | sudo tee -a wordpress.conf echo ' Require all granted' | sudo tee -a wordpress.conf echo '</Directory>' | sudo tee -a wordpress.conf echo '<VirtualHost *:80>' | sudo tee -a wordpress.conf echo 'serverAdmin webmaster@localhost' | sudo tee -a wordpress.conf echo 'DocumentRoot /srv/www/wordpress' | sudo tee -a wordpress.conf echo '</VirtualHost>' | sudo tee -a wordpress.conf




This is what wordpress.config file looks like, You can type in CTRL+X to exit out of the nano editor.




Enable SSL

We will run the below command to enable the SSL mode for your website, after enabling SSL we will restart the Apache server.

sudo a2enmod sslsudo  
systemctl restart apache2




Configure MYSQL Database

Now we will set up our MYSQL Database and will configure “Database name“, “Database username“, “Database password“, “Database host”  &  “Table prefix“. Please make sure to use the database, username & password of your own choice or you can just run the below queries by only changing the database password.

sudo mysql -u root CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'Password@12345'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost'; FLUSH PRIVILEGES; quit;




Configuring “WP-CONFIG.PHP” File

Once we have created DATABASE & USER-related entries in MYSQL, we need to add the same entries in our “WP-CONFIG.php” file. we will run the below commands to add the entries.

Please note that the USERNAME, DATABASE NAME, and PASSWORD details of the WP-CONFIG file should match with the entries of the MYSQL database.

sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php sudo -u www-data sed -i 's/database_name_here/wordpress/' /srv/www/wordpress/wp-config.php sudo -u www-data sed -i 's/username_here/wpuser/' /srv/www/wordpress/wp-config.php sudo -u www-data sed -i 's/password_here/Password@12345/' /srv/www/wordpress/wp-config.php




You can go to the location “/srv/www/wordpress/” and validate the entries by issuing the command “sudo nano /srv/www/wordpress/wp-config.php




It's Done !! Configuring the WordPress

Now, I am using Google Cloud and I have created a Virtual machine that has an external IP address of 34.125.187.92, I can go ahead and paste that IP address into my browser and we will be greeted with a WordPress installation screen. 



yes!!! it’s done your website is running on a Google Cloud Virtual machine, if you are using any other Cloud service like AWS or Azure you can easily find the External IP address in the instance you created.




This is an important part as this step will install SSL for your WordPress website.

sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php sudo -u www-data sed -i 's/database_name_here/wordpress/' /srv/www/wordpress/wp-config.php sudo -u www-data sed -i 's/username_here/wpuser/' /srv/www/wordpress/wp-config.php sudo -u www-data sed -i 's/password_here/YourPassword/' /srv/www/wordpress/wp-config.php

This is an important part as this step will install SSL for your WordPress website.

echo '' | sudo tee .htaccess echo 'php_value upload_max_filesize 500M' | sudo tee -a .htaccess echo 'php_value post_max_size 500M' | sudo tee -a .htaccess echo 'php_value memory_limit 500M' | sudo tee -a .htaccess sudo service apache2 reload

This is an important part as this step will install SSL for your WordPress website.

sudo snap install core; sudo snap refresh core sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot sudo certbot certonly --apache --non-interactive --agree-tos -m mukesh.bpo@live.com -d www.learnages.com

Post a Comment

0 Comments