Create a Micro VM Instance on Google Cloud Platform
1. Go to https://console.cloud.google.com/ and create a micro VM instance.
2. Machine type: f1-micro (1 vCPU, 0.6 GB memory)
3. Zone: us-central1-a
4. Boot Disk: Ubuntu XX.XX LTS
5. Disk size: 30GB
6. Please see this info “Your first 744 hours of f1-micro instance usage are free this month.” on the right side of the screen.
7. Allow http and https traffic.
8. And create.
Create a Swap File
1. After creating the VM, SSH into it and firstly do this to improve the performance of your micro instance:
sudo fallocate -l 1G /swapfile
2. Do dd to wipe this file out:
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
3. Make it readable only by root:
sudo chmod 600 /swapfile
4. Now we can make the swap:
sudo mkswap /swapfile
5. Turn it on:
sudo swapon /swapfile
6. Make sure to open the following file and see the defaults are 0 0:
sudo nano /etc/fstab
7. Make sure you did not do any misspellings:
sudo mount -a
8. Do the following and see your new Swp is 1024MB:
cd
htop
LAMP Stack Installation
1. Use tasksel to install Apache, MYSQL, and PHP:
sudo apt install tasksel
2. Install the lamp server:
sudo tasksel install lamp-server
3. To meet the all requirements, install the rest of our dependencies:
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc
Domain Name Configuration
1. Know your website’s IP:
curl ifconfig.me
2. Let’s assume that you purchased a domain name. Add your site’s IP and domain name to the following place at the bottom and save it:
XX.XXX.XXX.XX sitename.com
Apache Configuration
1. To setup our domain name in our Apache configuration file, do:
cd /etc/apache2/sites-available/
ll
2. We have the default site. We have to make a copy of it and give it a name like “sitename.com.conf”:
sudo cp 000-default.conf sitename.com.conf
3. You can do the following to get superuser abilities to run as root (optional):
sudo su
4. After creating “sitename.com.conf” file, do:
cd /etc/apache2/sites-available/
sudo nano sitename.com.conf
5. Add the following at the top:
<Directory C:\xampp\htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
6. If you are working on an nginx server it should look like this:
upstream example-php-handler {
server unix:/var/run/php/php7.4-fpm.sock;
}
server {
listen 80;
server_name sitename.com www.sitename.com;
root /var/www/wordpress;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass example-php-handler;
}
}
7. And change/add the following:
ServerName sitename.com
ServerAlias www.sitename.com
8. In order to disable the default site do the following:
a2dissite 000-default.conf
9. In order to set your new website as the default site, do the following:
a2ensite sitename.com.conf
10. Just reload Apache2 by doing:
systemctl reload apache2
MySQL Configuration
1. Create a database and grant permissions to the user. Make sure you remember your database name, user name, and password:
mysql -u root
CREATE DATABASE databasename;
GRANT ALL ON databasename.* TO ‘username’ IDENTIFIED BY ‘password’;
quit
2. Secure the installation and answer all the questions until see ‘All done!’:
mysql_secure_installation
PHP Configuration
1. Go to the PHP directory and edit ‘php.ini’:
cd /etc/php/7.X/apache2
sudo nano php.ini
2. Do the following:
max_input_time = 30
upload_max_file_size = 20M
post_max_size = 21M
3. Save and exit.
Install WordPress
1. Go to the root:
cd
2. Move index.html file to a lower directory:
cd C:\xampp\htdocs
ll
mv intex.html
ll
3. Get the latest WordPress:
wget https://www.wordpress.org/latest.tar.gz
4. Extract the files:
tar -xvf latest.tar.gz
5. We want all files to be in the lower directory which is the html directory:
cd wordpress/
mv * ..
cd ..
ll
6. Remove wordpress folder:
rm wordpress/ -r
7. Remove latest.tar.gz file:
rm latest.tar.gz
8. Go to your website and install your WordPress.
Tuning
1. Open and modify the following:
nano /etc/apache2/mods-enabled/mpm-prefork.conf
2. Do the following and save:
StartServers 1
MinSpareServers 2
MaxSpareServers 5
MaxRequestWorkers 10
MaxConnectionsPerChild 1000
3. Install the following script:
cd
wget https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl
4. Make it writeable:
chmod +x apache2buddy.pl
5. Run the script and make the recommended changes if necessary:
./apache2buddy.pl
Credits
https://christitus.com/wordpress-google-cloud-platform/
https://www.youtube.com/watch?v=vIJdypOqlL4&ab_channel=ChrisTitusTech
https://www.youtube.com/watch?v=f56PG7QxjFI&ab_channel=TonyTeachesTech