Categories
Uncategorized

Simplified

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install tasksel
  • sudo tasksel
    • Ubuntu Cloud Image
    • LAMP server
    • OpenSSH server
    • Basic Ubuntu server
  • sudo chown -R baykoe:www-data /var/www
  • sudo wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  • sudo chmod +x wp-cli.phar
  • sudo mv wp-cli.phar /usr/local/bin/wp
  • sudo apt-get install subversion
  • wp config create –dbname=testing –dbuser=baykoe –dbpass=securepswd –locale=ro_RO
  • sudo wp core install –url=”your_domain” –title=”Blog Title” –admin_user=”admin username” –admin_password=”enter_your_password” –admin_email=”enter_your_email”

Can I just create a simple script and upload files to setup a raw WordPress environment on a virtual machine instance?
I would think that I could.
Does MySQL work with a script?

I need to choose between using the WP-CLI tool or Subversion.
Subversion

Best concept have an image of a machine that is all set for WordPress except for the WordPress files.
Don’t rush the install but get everything just right. Maximize for a small instance. Have the raw tools for testing installed.

Categories
Uncategorized

Build WordPress from Source

Install node.js
# apt-get install node.js
Download WordPress Source code
# cd ~
# svn co https://develop.svn.wordpress.org/trunk wordpress-core
Build
# cd wordpress-core
# npm install –save core-js@^3
# npm install -g grunt core-js@^3
# npm install -g grunt-cli core-js@^3
# npm install
# npm run build:dev
# npm run env:start
# npm run env:install
Then to stop the environment
# npm run env:stop
To run the WP-CLI tool see https://make.wordpress.org/cli/handbook
# npm run env:cli
From WP-CLI can run lots of commands including tests
-For PHP Tests
# npm run test:php
-for E2E (end to end) Tests
# npm run test:e2e

Fix NPM errors
Error: Cannot find module ‘uglifyjs-webpack-plugin’
# npm install –save uglifyjs-webpack-plugin
WARN uglifyjs-webpack-plugin@2.2.0 requires a peer of webpack@^4.0.0 but none was installed.
#npm install –save webpack@^4

Get WP-CLI
# wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Then, check if it works:
# php wp-cli.phar –info
To be able to type just wp, instead of php wp-cli.phar, you need to make the file executable and move it to somewhere in your PATH. For example:
# chmod +x wp-cli.phar
# mv wp-cli.phar /usr/local/bin/wp
Now try running
# wp –info

From Slack Making WordPress Core Channel
3/25/2020
Message #core
danr
Mar 25th at 11:39 PM
Does npm run build not copy the js files?
mike
Mar 25th at 11:40 PM
I usually run grunt build, which I think does. If it’s set to use the build directory for JS (I think that’s the same as npm run build?)
noisysocks
Mar 25th at 11:40 PM
Yeah npm run build / grunt build / npm run watch / grunt watch should all copy things from src to build (whereas npm run build:dev / grunt build –dev / npm run dev / grunt watch –dev all build from src into src )

Categories
Uncategorized

Compile WordPress from Source on Google Cloud virtual Linux Machine

Objectives:

  • On a remote machine (Google Cloud VM instance)
  • Use basic scripts to create and destroy systems quickly and easily
  • Without using VVV (I have not got it to work in this environment)
    • We may be able to use VVV scripts to learn what to do
  • Be able to work on WordPress Core
    • Compile code to WordPress
    • Run Unit Tests
    • Check Changes

Install Subversion
# apt-get install subversion
Install Node.js
# apt-get install node.js
Install NPM
# apt-get install npm
# npm update -g npm
Install Grunt CLI
# npm install -g grunt-cli


Here is some info on how it is done from WordPress Core.

Install using Subversion and command line.

Creating a WordPress site using SVN

Another idea

E2E (End to End Testing ) using Docker

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.