Set up WordPress on a new LAMP+NGINX server

Work in Progress…

This tutorial is about installing LAMP + NGINX as a reverse proxy + WORDPRESS on a new remote server (VPS or dedicated). This guide does not cover the Linux-installation itself: Linux should already be installed on the server. Here is our “LAEMP” stack:

  • Linux (Ubuntu 16.04 LTS minimal)
  • Apache
  • (E)NGINX as a reverse proxy
  • MySQL
  • PHP7
  • WordPress

Content

Connect to server via SSH

On Windows, download the free Putty utility. On Linux, use a terminal:
ssh root@your.server.ip.address -p22

Check your hoster for your servers IP-address and the port to connect.

Alternatively, use ssh keys instead of password:
SSH login without password using SSH keys

Change root password, create new user with sudo privileges

Change the root password:
passwd

This command changes the password for the current user, which is fine now as you are probably logged in as root.

Create a new user:
adduser username

Add sudo priviledges:
usermod -aG sudo username

Update packages

Starting with Ubuntu 16.04, no need to use apt-get anymore, apt is enough.

Update the list of available updates:
sudo apt update

Upgrade the current packages:
sudo apt upgrade

Or combine both in one line:
sudo apt update && sudo apt upgrade

Now the server is ready to install LAMP. Two reference articles:

DigitalOcean: How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04
Tecmint: How to Install LAMP with Apache, PHP 7 and MariaDB 10 on Ubuntu 16.04 Server

Install ufw firewall

Install a firewall:
sudo apt install ufw

Make sure the firewall will let through SSH connections (important!) and Apache traffic. Ufw has presets for both. Display the presets for these applications:
sudo ufw app list

To get more information on a profile, use:
sudo ufw app info "Apache Full"

Allow OpenSSH and Apache connections:
sudo ufw allow OpenSSH
sudo ufw allow in "Apache Full"

Now that SSH is allowed, enable the Firewall (confirm with “y”):
sudo ufw enable

Activating Ufw Firewall on remote server

Install Apache

sudo apt update
sudo apt install apache2

Or combine both in one line:
sudo apt update && sudo install apache2

Test if Apache is running:
sudo systemctl status apache2.service

Use the –no-pager and –full options to avoid horizontal scrolling
sudo systemctl status apache2.service --no-pager --full

Use systemctl to check if Apache is running on a LAMP stack.

 

Hit Q to exit systemctl.

Solution for the following error:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name

The digital Ocean guide has a solution, see “Set Global ServerName to Suppress Syntax Warnings”

Test Apache in browser:
http://your.server.IP.address

Apache SSL modules

Check Tecmint’s guide to enable Apache SSL modules.

Useful commands

sudo netstat -tlpn

 

Install php7

run the following commands in ubuntu 16.04 server command prompt this will install apache2 supported module for php7

sudo apt-get -y install php7.0 libapache2-mod-php7.0
After the installation you need to Restart the apache2 server using the following command

sudo systemctl restart apache2

Posted in Allgemein.

Post a comment