Order of installation of LAMP components

Here is how I install my new WordPress Server LAMP ( Linux, Apache2, MariaDB (MySql), and PHP components.

I have spend 8+ years gathering the notes on this web site for WordPress installations.  I have researched configurations and issues.   I have developed a best practices methodology for installing all the components.  Before I was on Windows 7 IIS web site.   In 2015, WordPress was in 3.8.x.  I do remember WordPress 5.x because of issues with CentOS 7.   CentOS 7 was released in 2014.  

My current OS: Feb. 2024

Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 6.5.0-18-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro

System information as of Wed Feb 21 07:37:39 PM EST 2024

System load: 0.0
Usage of /: 8.4% of 48.91GB
Memory usage: 8%
Swap usage: 0%
Processes: 181
Users logged in: 0
IPv4 address for ens32: 192.168.1.10
IPv6 address for ens32: 2600:1700:b101:808f:20c:29ff:fea5:7fec

=> /swap_space is using 99.8% of 9.74GB

The server is behind a firewall with virtual IPs.  I do apply patches to Ubuntu Pro a few times a week.  My web server does use IPv4 and IPv6.  

df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 994M 2.7M 991M 1% /run
/dev/sdb1 49G 4.2G 43G 9% /
tmpfs 4.9G 1.2M 4.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sdd1 9.8G 9.8G 0 100% /swap_space
/dev/sda2 1.5G 290M 1.1G 22% /boot
/dev/sdc1 492G 12G 455G 3% /var
tmpfs 994M 4.0K 994M 1% /run/user/1000

My next server installation will decrease /var because I no longer have the web site for my children’s pictures.  I have over 400 GB of pictures and videos.  The root partition has a lot of room to grow for MariaDB.  /Swap_Space was created to add swap space.  It will go away in the next installation.   I have pages on Ubuntu under Linux.  

free -h
total used free shared buff/cache available
Mem: 9.7Gi 654Mi 7.0Gi 131Mi 2.1Gi 8.6Gi
Swap: 9.7Gi 0B 9.7Gi

HTOP is a great tool in Ubuntu.   I use it to see how the LAMP components are functioning.   MariaDB has over a dozen threads.  My server has the resources for my configuration.   

Create your virtual server

1.) Create the VMWare Virtual Machine

I create separate Vdisks.   All are thin provisioned
/boot gets 1.5 to 2 GB. 

Yes, Ubuntu stores 290 MB for the boot files.  When the server installs the new kernel files, it can grow.  Unless you run sudo apt autoremove and sudo apt autoclean it can grow.  Disk space is cheap on my server.

/ (root Parition) gets 25-50 GB.

I separate / and /var on to two separate Vdisks.

The root partition is for the Apache2, SQL and PHP files.  It has the /etc folder.  Under this is apache2 and php.  It has the conf files for each virtual server.   My server is using 4.2 GB.  I could go back to 25GB for the root partition.  I have plenty of disk space at home.  

/var gets 50 GB to 1 TB of disk space. 

This is where /var/www is stored.  All your WordPress virtual servers.  I currently has 7 of them.  web sites, phpMyAdmin, and a few other apps with web sites.  phpMyAdmin is used to configure your SQL server be it MySQL or MariaDB.   Check out PHP for WordPress for all the notes on it.  

/swap is the swap file space. 

My web server has 10GB of vRAM, 4 vCPUs, and Gigabit e1000 NIC.   The size of the space space is usually 50% of the ram.  I rarely see it used on my web servers.   I found the web server boots faster and runs better with 10 GB of RAM.  The server has 80 GB.   It isn’t expensive to upgrade RAM.   I have 5.5 TB of RAID 10 storage.   WordPress has been modified in the PHP files to use 768M for uploading files and pictures. 

Install your operating system

I used Ubuntu LTS versions for my web server.  They have 5 years of support.  Every two years a new release comes.   April of 2024 will be Ubuntu 24.04 LTS.  I usually wait till September to November to create a new VM.  Ubuntu Pro gives you 5 servers for free.  

VMWare 6 doesn’t allow LVM partitions to be used.  So I manually create each partition listed above.   Once Ubuntu is installed and up and running, I add it to Ubuntu Pro to get better security features.   I install all the patches and new kernels before I do anything else.  I want to be on the latest and greatest.

Apache 2 is installed next

sudo add-apt-repository ppa:ondrej/apache2
sudo apt update
sudo apt install apache2

This is the most common way to install Apache 2.  You will find all my Apache 2 notes in the link at the top of this second. How to enable SSL and other components needed for a web site.  My web sites are TLS 1.2 and 1.3 compliant.  I test with https://www.ssllabs.com/ . The notes on my Apache 2 configuration file for my virtual servers is included along with all the security settings, crypto and keys, etc. 

MariaDB is open source.  MySQL is owned and sold. 

The link above has my MariaDB 11.x notes.  It states the MariaDB LTS version 10.11.   I installed 11.2.2 because of performance issues.   I explain how to change the log locations.   Change the heap memory and other settings to increase its performance. 

PHP 8.3.x

The link above has all my notes on PHP 8.3.x.  I list all the components that you need to install for WordPress 6.4.x.

sudo apt install php8.3 libapache2-mod-php8.3 php8.3-common php8.3-mysql php8.3-gmp php8.3-curl php8.3-intl php8.3-mbstring php8.3-xmlrpc php8.3-gd php8.3-xml php8.3-cli php8.3-zip php8.3-bcmath php8.3-imagick php8.3-fpm php8.3-bz2 php8.3-soap

How do I install a WordPress server.

1.) Create /var/log/apache2/”your web site name”  : This is in your /etc/apache2/sites-available/config file for the virtual host
2.) create /var/www/”your web site name/public_html” : This is in your /etc/apache2/sites-available/config file for the virtual host
3.) in /etc/apache2/sites-available, I create “your web site name”.conf
4.) I give the /var/www/”your web site name” chown to your user to copy in stuff.  When done, chown www-data:www-data for the site.   I use Ubuntu.  Redhat is different.
5.) I usually put the new domain in my Godaddy certificate and generate a new certificate and apply it to everything first.  
6.) Set up .htaccess in wp-admin for only your require ip that are inside your network or you VPN with
sudo wget https://wordpress.org/latest.tar.gz
Then extract the package using: sudo tar -xzvf latest.tar.gz

7.) I copy the wordpress folder contents to the public_html folder and after the site is up delete the latest.tar.gz file.  You won’t need it.   The “your web site”.conf file will point to the public_html folder.
8.) Open PHPMyAdmin on the server and create the WordPress database and SQL User for the wp-config.php file
9.) Create the salt :  https://wpbuffs.com/wordpress-security-keys-salts/
10.) Go into your site’s wp-admin and configure the web site and set it up.

Last thing:    I move the wp-config.php file
Move the wp-config.php inside wp-admin to /home/”my user/”your web site”/config.php”

I change the wp-config.php file in WordPress to:

<?php
include(‘/home/”your name”/”your web site”/config.php’);      Point it to the correct location where you moved the file to.  
?>