WordPress Install – CLI

StepCommandDescription
1~$ ssh root@host-urlUsing your client computer, establish a terminal session on your server host using root account. Use your server host’s network address for “host-url”.
2~# adduser wp-opsAdd the “wp-ops” user id for WordPress administration.
3~# usermod wp-ops -aG sudoAdd the “wp-ops” user id to the sudo group.
4~# exitTerminate terminal session.
5~$ ssh wp-ops@host-urlEstablish a terminal session on your server host using “wp-ops”.
6~$ sudo apt updateUpdate your system’s repository listing.
7~$ sudo apt upgradeUpdate your system’s software.
8~$ sudo apt install apache2Install the Apache2 package.
9~$ sudo chown -R www-data:www-data /var/www/html/Change ownership of the Apache2 root directory (recursively) to the Apache2 service’s user-id and group. (www-data)
10~$ sudo usermod -aG www-data wp-opsAdd the “wp-ops” user id to the Apache2 “www-data” group.
11OPTION 1:
~$ sudo nano /etc/apache2/mods-enabled/dir.conf

OPTION 2:
~$ sudo rm /var/www/html/*
OPTION 1:
Using “nano” or another text editor, change the second line of this file from this:

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml inde$

To this:

DirectoryIndex index.php index.cgi index.pl index.index index.xhtml inde$

Option 2:
remove all files from the Apache2 root directory.
12~$ sudo systemctl reload apache2Restart Apache2 so the changes to the configuration file will take effect.
13~$ sudo systemctl status apache2Verify Apache2 is running. Press “q” to exit the display.
14~$ sudo apt install phpInstall the PHP package.
15~$ sudo apt install libapache2-mod-phpInstall the package with the libapache2-mod-php extension.

Note: PHP extensions may be installed due to dependencies in pervious packages. This causes no problems.
16~$ sudo apt install php-curlInstall the package with the php-curl extension.
17~$ sudo apt install php-cliInstall the package with the php-cli extension.
18~$ sudo apt install php-mysqlInstall the package with the php-mysql extension.
19~$ php -vVerify PHP is running and it’s version number.
20~$ sudo apt install mysql-serverInstall the MySQL package.
21~$ sudo mysql_secure_installationRun the MySQL installation script and respond to prompts as necessary.
22~$ sudo MySQL
mysql> create database wp_database;
mysql> exit
Create a database for WordPress. My example uses “wp_database” as the database name. Use any name you choose.
23
24
25
26