What is a LAMP stack?
LAMP is a set of four programs that work together. L is Linux, the operating system. A is Apache, the web server that sends pages to visitors. M is MySQL, the database that stores your content. P is PHP, the language WordPress runs on.
A command line is a text window where you type instructions. You use it for every step below. Log in to your server over SSH as root, or as a user who can run sudo.
Tip: Ubuntu 18.04 is old. Newer Ubuntu versions use almost the same steps, though some package names differ.
Steps
- Update the package list.
This refreshes the list of software and installs updates.sudo apt update && sudo apt upgrade -y - Install Apache, MySQL and PHP.
This installs the whole stack and the PHP parts WordPress needs.sudo apt install apache2 mysql-server php php-mysql php-curl php-gd php-mbstring php-xml php-zip libapache2-mod-php -y - Open the MySQL prompt.
sudo mysql - Create a database and a user. Replace the name and password with your own.
This makes a database and a user who may use only that database.CREATE DATABASE wpdb DEFAULT CHARACTER SET utf8mb4; CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPasswordHere'; GRANT ALL ON wpdb.* TO 'wpuser'@'localhost'; FLUSH PRIVILEGES; EXIT; - Download WordPress.
This fetches and unpacks the newest WordPress files.cd /tmp curl -O https://wordpress.org/latest.tar.gz tar -xzf latest.tar.gz - Copy the files to the web folder.
sudo cp -a /tmp/wordpress/. /var/www/html/ sudo rm /var/www/html/index.html - Give Apache ownership of the files.
sudo chown -R www-data:www-data /var/www/html - Turn on pretty links.
For pretty links to work, setsudo a2enmod rewrite sudo systemctl restart apache2AllowOverride Allfor/var/www/htmlin your Apache site file, then restart Apache again. - Open your server's IP address or domain in a browser.
- Enter the database name, user and password from step 4. Use
localhostas the host. - Choose a site title, admin username and strong password, then click Install WordPress.
After the install
- Set up a firewall so only needed ports are open.
- Add an SSL certificate so your site uses https.
- Take regular backups.
Quick recap
- LAMP means Linux, Apache, MySQL and PHP.
- Install the stack, create a database, then copy WordPress to
/var/www/html. - Set the right file owner, then finish the setup in your browser.
- You need root access for these steps.