Categories
Uncategorized

Hello WordPress World!

Create a micro instance of a Linux OS on Google Cloud
As you setup the machine jump into root save root password

$ sudo passwd root
$ su

Update system
# apt update && sudo apt upgrade

Create a Swap file
# fallocate -l 1G /swapfile
# dd if=/dev/zero of=/swapfile bs=1024 count=1048576
Restrict access to root
# chmod 600 /swapfile
# mkswap /swapfile
Turn it on
# swapon /swapfile
Change here so it turns on at reboot
Add this line to the end of the file

# cd /etc/
# nano /etc/fstab
swapfile swap swap defaults 0 0
After saving and closing editor check that it is correct
# mount -a
See the results
# htop

Install LAMP Stack (Linux, Apache, MySQL and PHP)
# apt install tasksel
# tasksel install lamp-server
# apt install php-curl php-gd php-mbstring php-xml php-xmlrpc

Point DNS to your fixed IP
Add reference file to your Apache2

# cd /etc/apache2/sitesavailable/
Refer to your URL
# cp 000-default.conf kc7efq.tk.conf
Edit the file
# nano kc7efq.tk.conf
Edit Line remove comment
#ServerName www.example.com
becomes:
ServerName kc7efq.tk
and add
ServerAlias www.kc7efq.tk
Then at beginning of file add
<Directory /var/www/html>
Require all granted
</Directory>
Save and exit
Disable the default site
# a2dissite 000-default.conf
Enable the new site
# a2ensite kc7efq.tk.conf
Reload Apache and start the new configuration
# systemctl reload apache2
At this point you can test Apache by going to the URL or the IP address if URL has not yet been propagated. You will see the Apache2 Default Page

Prepare the MySQL database
Start MySQL using user root
# mysql -u root
In MySQL create a database for WordPress with user name and Password
You will need to have access to the:
Database name
Username
User Password

mysql> CREATE DATABASE wordpress;
mysql> GRANT ALL ON wordpress.* to ‘wordpressuser’ IDENTIFIED BY ‘pa55word’;
mysql> quit
Secure the installation and save the new passwords
# mysql_secure_installation

Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y

Please enter … 2 = STRONG: 2
Set root password and remember it.
Answer Y to the rest of the prompts.

Do PHP modifications
# cd /etc/php/7.2/apache2/
Modify php.ini
# nano php.ini
Make changes for a small system
max_input_time = 60 becomes
max_input_time = 30
upload_max_filesize = 2M becomes
upload_max_filesize = 20M or as appropriate for the website
post_max_size = 8M becomes
post_max_size = 25M or as appropriate, a little larger than max file size
Save file and exit.

Install WordPress
Fork here if you are going to
compile WordPress from source code
# cd /var/www/html/
# ll
Remove the Apache2 Default Page
# rm index.html
# wget https://wordpress.org/latest.tar.gz
Unzip and install
# tar -xzvf latest.tar.gz
It was actually installed in /var/www/html/wordpress/ and we want it in /var/www/html/
# cd /wordpress/
# mv * ..
# cd ..
# ll
As you can see all files are moved. We will remove the empty WordPress directory and the tar file.
# rm wordpress/ -r
# rm latest.tar.gz
Create configuration for WordPress
# cp wp-config-sample.php wp-config.php
And edit the newly copied file
# nano wp-config.php
Update MySQL settings to what you created earlier
/** The name of the database for WordPress */
define( ‘DB_NAME’, ‘database_name_here’ );
/* MySQL database username */
define( ‘DB_USER’, ‘username_here’ );
/* MySQL database password */
define( ‘DB_PASSWORD’, ‘password_here’ );
Update the security codes with randomly generated key from here.
Add the following code to the end of the file.
/** Sets to automatically update WordPress without FTP*/
define(‘FS_METHOD’,’direct’);
Save file and exit.
Fix WordPress permission errors.
# chown -R user-name:www-data /var/www

Now you can edit the basic WordPress site. Go to the URL or IP.

Coming back to the back end of your machine, you can now tune your micro instance of WordPress.
# nano /etc/apache2/mods-enabled/mpm_prefork.conf
Set up as follows for a micro instance.
StartServers 1
MinSpareServers 2
MaxSpareServers 5
MaxRequestWorkers 10
MaxConnectionsPerChild 1000
Save file and exit.

Add a Perl script to maximize Apache
# cd ~
# wget https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl
Change permissions to let script run.
# chmod +x apache2buddy.pl
Run the script.
# ./apache2buddy.pl
It will review how your system is running. Run this script after the site has been running for awhile.

Leave a Reply

Your email address will not be published. Required fields are marked *