Host Wordpress Website In GCP
Host Wordpress Website In GCP
Step 1: Create an Instance.
Step 2: Install Apache server,PHP,MySql on Instance.
a)Install Apache and PHP:
sudo yum check-update
sudo yum -y install httpd php
b)Start the Apache service:
sudo service httpd start
sudo chkconfig httpd on
Step 3: Test Apache
For this step, you need the external IP address of your instance. You can look up the address in the VM Instances page in the Cloud Platform Console.
In a browser, enter your external IP address to verify that Apache is running:
http://[YOUR_EXTERNAL_IP_ADDRESS]
You should see the Apache test page.
Step 4: Install MySQL on your instance
Install MySQL and related PHP components:
Install MySQL and related components:
sudo yum -y install httpd mysql-server php php-mysql
Start the MySQL service
a)sudo service mysqld start
b)sudo mysql_secure_installation (Configure MySQL)
Step 5: Configure the httpd.conf file.(/etc/httpd/conf/httpd.conf).
Step 6: Add Virtual host at the end of httpd.conf file.
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html/[Project folder]
ServerName www.example.com
ServerAlias example.com
# ErrorLog /var/www/example.com/error.log
# CustomLog /var/www/example.com/requests.log
</VirtualHost>
Step 7: Comment out all line of welcome.conf file (/etc/httpd/conf.d/welcome.conf)
Migration:
Step 1: Copy project file to /var/www/html/
Step 2: Create Database on Instance (create database database_name;)
Step 3: Import database file to project explicitly (mysql -u root -p database_name<dump.sql)
Step 4: Restart httpd and mysql.
Step 5: You need to modify siteurl and home value to IP address of an Instance through SQL query. Siteurl and Home attributes are present on wp_options table.