Installing WordPress on a Linux (LAMP) Server
Posted 03-16-2017 at 10:15 AM by beachboy2
Updated 04-18-2020 at 09:46 AM by beachboy2 (Adding screenshots)
Updated 04-18-2020 at 09:46 AM by beachboy2 (Adding screenshots)
Plan:
Install an Apache2 web server on Linux with PHP 7.0 (mod_php) and MySQL support. Then install WordPress and create your own website or blog, either just for testing/learning, or live transmission via a web host.
LAMP is short for Linux, Apache, *MySQL, PHP.
A LAMP setup is perfect for a Content Managed System like Wordpress:
https://codex.wordpress.org/
(*Alternatively, you can use MariaDB from the original developers of MySQL. It is guaranteed to stay open source).
It is a good idea to test your WordPress website locally, using localhost (http:/127.0.0.1), before uploading it later to your live server, hopefully without any errors, bugs or security flaws.
To move your website later, I recommend Method 2 on “How To Move Your WordPress Website From localhost To Live Server”:
http://www.wpexplorer.com/wordpress-local-to-live/
You may prefer to just run a WordPress “test” website on a LAMP server using a spare PC/laptop via localhost and never actually go “live” on a hosted production server.
I first installed Linux Mint 18.1 MATE as the base Linux distribution, as opposed to Ubuntu Server 16.04.2, CentOS or Debian etc. The choice is entirely yours.
Install Apache
To install Apache, enter:
Enable and start your apache (as root):
Test Apache:
Open your web browser and navigate to http://localhost/ (localhost is http:/127.0.0.1)
Install MySQL (or MariaDB):
During installation, you will be asked to setup the MySQL “root” user password. Enter the password myrooting874tootING?! and click OK. Repeat.
MySQL is being installed now.
You can verify the MySQL server status using command:
Next, harden the security on MySQL using the following configuration script:
Apart from the current root password, which is retained, select Y (Yes) to everything else.
Install PHP 7.0
Install PHP with following commands:
Restart apache2:
Then test your php:
To test PHP, create a sample “testing.php” file in the Apache document root folder, which is: /var/www/html
Copy and paste the following lines to the file:
Save the changes by using Ctrl+O, then press Enter. Exit using Ctrl+X.
Restart apache2 service:
Navigate to http://localhost/testing.php
It will display all the details about php such as version, build date and commands etc.
Next, for security, remove the “testing.php” file:
Install phpMyAdmin
Select the web server that should be automatically configured to run phpMyAdmin. In my case, it is apache2.
Use the spacebar to insert * inside brackets for apache2, press Tab and Enter. Ignore lighttpd.
The phpMyAdmin must have a database installed and configured before it can be used. This can be optionally handled by dbconfig-common.
Select ‘Yes’ to configure database for phpmyadmin with dbconfig-common.
Enter MySQL application password (rarely used) for phpmyadmin: somethingorother
(NOT myrooting874tootING?! which is the root MySQL password).
Re-enter password.
Success! phpMyAdmin installation is installed.
If you followed all steps carefully, phpMyAdmin should work just fine.
In case phpMyAdmin is not working, please do the following:
Open terminal, and type:
Add the following line at the end:
Save and Exit.
Restart apache service:
Access phpMyAdmin Web Console
Navigate to:
http://localhost/phpmyadmin/ from your browser.
Enter your MySQL username and password which you have given in previous steps. In this case: root and myrooting874tootING?!
You will be redirected to phpMyAdmin main web interface.
From here, you can manage your MySQL databases from phpMyAdmin web interface.
Your LAMP stack is ready to use.
.......................................................................................
Wordpress Database Initialisation
NB wp-config is located at: /var/www/html/wordpress/wp-config.php
Create the database for Wordpress as follows:
Login to the MySQL database as root user:
Type the MySQL root password myrooting874tootING?! and press Enter.
At the mysql > prompt create a database with:
Name: fredjdb
Database user: fredj and the
Database password: amotv769TZG?$
THIS IS STEP 2 (referred to later when installing WordPress).
At the mysql > prompt, enter the following 3 lines separately, including the semi-colon (;) at the end. Press Enter after adding each line:
Then exit the MySQL shell using the following commands and pressing Enter:
Next, restart services using:
Install WordPress
Go to: https://wordpress.org/download/
Download wordpress-4.7.3.gz to Desktop and then extract the wordpress folder:
Move the extracted wordpress folder on Desktop to /var/www/html/ using:
Now DELETE index.html.
If both index.html and index.php are present, index.html loads first overriding the index.php file:
Remove the index.html file from the html folder containing wordpress:
Now set appropriate permissions for the wordpress directory. NB You MUST be root user to do this!
Next, create the uploads directory beneath the wp-content directory at our document root. This (wp-content) will be the parent directory of our content:
We need to allow the web server itself to write to this directory. We can do this by assigning user and group ownership of this directory to our web server user www-data.
This will allow the web server to create files and directories under this directory, which will permit us to upload content to the server.
Proceed like this, as root user:
Now proceed to the web installation of Wordpress.
Go to the URL http://localhost/wordpress/ in your web browser. The WordPress installer will show up.
Select English language and press Continue:
The Welcome screen shows up in the selected language. Click on Let's go and type in the Login details of the WordPress database that was created in STEP 2 previously.
The database host is "localhost" and the prefix can be left at its default. Then click on the "Submit" button.
Wordpress saves the database configuration details to the file:
/var/www/html/wordpress/wp-config.php
Click on "Run the install" to proceed to the next part of the installer.
Now enter some details for the Blog like website title, admin username, password and email address.
Site Title = Fred’s Blog
Admin Email = fred@some_email_address
Username = Fred
Admin password = wqm97168LV
Press InstallWordpress to finish the installation.
Next, access the login page by pressing LogIn:
Type in the credentials that you selected during WordPress installation above. The WordPress Dashboard will then appear.
Later, access your live WordPress website via:
http://YOUR-IP-ADDRESS/wp-admin
............................................................................................
For Reference
WP LOGIN: localhost/wordpress/wp-login.php
Welcome page: localhost/wordpress/index.php/welcome/
............................................................................................
Useful links (thanks to all, especially Till Brehm on HowToForge)
MariaDB:
https://mariadb.org/
WordPress:
https://codex.wordpress.org/
Ubuntu Server guides:
https://help.ubuntu.com/lts/serverguide/
https://help.ubuntu.com/lts/servergu...-overview.html
Wplift Guide:
https://wplift.com/install-wordpress-in-ubuntu
Unixmen:
http://www.unixmen.com/how-to-instal...-ubuntu-16-04/
How to Forge:
https://www.howtoforge.com/tutorial/...tu-16-04-lamp/
Ubuntu Desktop LAMP Development server:
https://www.jackreichert.com/2014/08...opment-server/
Hardening WordPress Security:
https://codex.wordpress.org/Hardening_WordPress
MySQL Security (very important):
http://howtolamp.com/lamp/mysql/5.6/securing/
Installing LAMP from source code:
http://howtolamp.com/lamp/
LAMP Server with WordPress (Raspberry Pi):
https://www.raspberrypi.org/learning...ess/worksheet/
How To Move Your WordPress Website From localhost To Live Server:
http://www.wpexplorer.com/wordpress-local-to-live/
Useful WordPress Plugins
BackWPup:
https://en-gb.wordpress.org/plugins/backwpup/
Akismet Anti-Spam:
https://en-gb.wordpress.org/plugins/akismet/
PDF Embedder:
https://en-gb.wordpress.org/plugins/pdf-embedder/
Easy Updates Manager:
https://en-gb.wordpress.org/plugins/...lugin-updates/
Gallery Manager:
https://wordpress.org/plugins/fancy-gallery/
.........................................................................................
Install an Apache2 web server on Linux with PHP 7.0 (mod_php) and MySQL support. Then install WordPress and create your own website or blog, either just for testing/learning, or live transmission via a web host.
LAMP is short for Linux, Apache, *MySQL, PHP.
A LAMP setup is perfect for a Content Managed System like Wordpress:
https://codex.wordpress.org/
(*Alternatively, you can use MariaDB from the original developers of MySQL. It is guaranteed to stay open source).
It is a good idea to test your WordPress website locally, using localhost (http:/127.0.0.1), before uploading it later to your live server, hopefully without any errors, bugs or security flaws.
To move your website later, I recommend Method 2 on “How To Move Your WordPress Website From localhost To Live Server”:
http://www.wpexplorer.com/wordpress-local-to-live/
You may prefer to just run a WordPress “test” website on a LAMP server using a spare PC/laptop via localhost and never actually go “live” on a hosted production server.
I first installed Linux Mint 18.1 MATE as the base Linux distribution, as opposed to Ubuntu Server 16.04.2, CentOS or Debian etc. The choice is entirely yours.
Install Apache
To install Apache, enter:
Code:
sudo apt-get install apache2
Code:
sudo su systemctl enable apache2 systemctl start apache2 systemctl status apache2
Open your web browser and navigate to http://localhost/ (localhost is http:/127.0.0.1)
Install MySQL (or MariaDB):
Code:
sudo apt-get install mysql-server mysql-client
MySQL is being installed now.
You can verify the MySQL server status using command:
Code:
sudo systemctl status mysql
Code:
sudo /usr/bin/mysql_secure_installation
Install PHP 7.0
Install PHP with following commands:
Code:
sudo apt-get update sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0 sudo apt-get install php-mbstring php7.0-mbstring php-gettext
Code:
sudo systemctl restart apache2
To test PHP, create a sample “testing.php” file in the Apache document root folder, which is: /var/www/html
Code:
sudo nano /var/www/html/testing.php
Code:
<?php phpinfo(); ?>
Restart apache2 service:
Code:
sudo systemctl restart apache2
It will display all the details about php such as version, build date and commands etc.
Next, for security, remove the “testing.php” file:
Code:
sudo rm -f /var/www/html/testing.php
Code:
sudo apt-get install phpmyadmin
Use the spacebar to insert * inside brackets for apache2, press Tab and Enter. Ignore lighttpd.
The phpMyAdmin must have a database installed and configured before it can be used. This can be optionally handled by dbconfig-common.
Select ‘Yes’ to configure database for phpmyadmin with dbconfig-common.
Enter MySQL application password (rarely used) for phpmyadmin: somethingorother
(NOT myrooting874tootING?! which is the root MySQL password).
Re-enter password.
Success! phpMyAdmin installation is installed.
If you followed all steps carefully, phpMyAdmin should work just fine.
In case phpMyAdmin is not working, please do the following:
Open terminal, and type:
Code:
sudo nano /etc/apache2/apache2.conf
Code:
Include /etc/phpmyadmin/apache.conf
Restart apache service:
Code:
sudo systemctl restart apache2
Navigate to:
http://localhost/phpmyadmin/ from your browser.
Enter your MySQL username and password which you have given in previous steps. In this case: root and myrooting874tootING?!
You will be redirected to phpMyAdmin main web interface.
From here, you can manage your MySQL databases from phpMyAdmin web interface.
Your LAMP stack is ready to use.
.......................................................................................
Wordpress Database Initialisation
NB wp-config is located at: /var/www/html/wordpress/wp-config.php
Create the database for Wordpress as follows:
Login to the MySQL database as root user:
Code:
sudo mysql -u root -p
At the mysql > prompt create a database with:
Name: fredjdb
Database user: fredj and the
Database password: amotv769TZG?$
THIS IS STEP 2 (referred to later when installing WordPress).
At the mysql > prompt, enter the following 3 lines separately, including the semi-colon (;) at the end. Press Enter after adding each line:
Code:
CREATE DATABASE fredjdb; CREATE USER fredj@localhost IDENTIFIED BY 'amotv769TZG?$'; GRANT ALL PRIVILEGES ON fredjdb.* TO fredj@localhost;
Code:
FLUSH PRIVILEGES; exit
Code:
sudo systemctl restart apache2 sudo systemctl restart mysql
Go to: https://wordpress.org/download/
Download wordpress-4.7.3.gz to Desktop and then extract the wordpress folder:
Code:
cd Desktop tar zxf wordpress-4.7.3.tar.gz
Code:
sudo mv /home/fred/Desktop/wordpress/ /var/www/html/
If both index.html and index.php are present, index.html loads first overriding the index.php file:
Remove the index.html file from the html folder containing wordpress:
Code:
sudo rm -r /var/www/html/index.html
Code:
sudo su chown -R www-data:www-data /var/www/html/wordpress chmod -R 755 /var/www/html/wordpress
Code:
sudo mkdir -p /var/www/html/wordpress/wp-content/uploads
This will allow the web server to create files and directories under this directory, which will permit us to upload content to the server.
Proceed like this, as root user:
Code:
sudo su chown -R www-data:www-data /var/www/html/wordpress/wp-content/uploads
Go to the URL http://localhost/wordpress/ in your web browser. The WordPress installer will show up.
Select English language and press Continue:
The Welcome screen shows up in the selected language. Click on Let's go and type in the Login details of the WordPress database that was created in STEP 2 previously.
The database host is "localhost" and the prefix can be left at its default. Then click on the "Submit" button.
Wordpress saves the database configuration details to the file:
/var/www/html/wordpress/wp-config.php
Click on "Run the install" to proceed to the next part of the installer.
Now enter some details for the Blog like website title, admin username, password and email address.
Site Title = Fred’s Blog
Admin Email = fred@some_email_address
Username = Fred
Admin password = wqm97168LV
Press InstallWordpress to finish the installation.
Next, access the login page by pressing LogIn:
Type in the credentials that you selected during WordPress installation above. The WordPress Dashboard will then appear.
Later, access your live WordPress website via:
http://YOUR-IP-ADDRESS/wp-admin
............................................................................................
For Reference
Code:
sudo systemctl start apache2 sudo systemctl start mysql
Welcome page: localhost/wordpress/index.php/welcome/
............................................................................................
Useful links (thanks to all, especially Till Brehm on HowToForge)
MariaDB:
https://mariadb.org/
WordPress:
https://codex.wordpress.org/
Ubuntu Server guides:
https://help.ubuntu.com/lts/serverguide/
https://help.ubuntu.com/lts/servergu...-overview.html
Wplift Guide:
https://wplift.com/install-wordpress-in-ubuntu
Unixmen:
http://www.unixmen.com/how-to-instal...-ubuntu-16-04/
How to Forge:
https://www.howtoforge.com/tutorial/...tu-16-04-lamp/
Ubuntu Desktop LAMP Development server:
https://www.jackreichert.com/2014/08...opment-server/
Hardening WordPress Security:
https://codex.wordpress.org/Hardening_WordPress
MySQL Security (very important):
http://howtolamp.com/lamp/mysql/5.6/securing/
Installing LAMP from source code:
http://howtolamp.com/lamp/
LAMP Server with WordPress (Raspberry Pi):
https://www.raspberrypi.org/learning...ess/worksheet/
How To Move Your WordPress Website From localhost To Live Server:
http://www.wpexplorer.com/wordpress-local-to-live/
Useful WordPress Plugins
BackWPup:
https://en-gb.wordpress.org/plugins/backwpup/
Akismet Anti-Spam:
https://en-gb.wordpress.org/plugins/akismet/
PDF Embedder:
https://en-gb.wordpress.org/plugins/pdf-embedder/
Easy Updates Manager:
https://en-gb.wordpress.org/plugins/...lugin-updates/
Gallery Manager:
https://wordpress.org/plugins/fancy-gallery/
.........................................................................................
Total Comments 1
Comments
-
Posted 03-16-2017 at 11:26 AM by Habitual