Download LAMP on Ubuntu 18.04
Introduction LAMP which stands for Linux, Apache, MySQL and PHP. With this combination you can easily host websites like WordPress on your own server
Step 1 – Install webserver In this guide we will be using Apache. Apache is the most popular webserver around.
Start by updating your Ubuntu sudo apt update Wait for updates to download and install
Install Apache2 sudo apt install apache2 Your web server is now active. Test it by entering your IP address in the browser, you should see the Apache2 default page
Step 2 – Install database Next step is to install the database.
Install MySQL sudo apt install mysql-server It’s possible that you’ll encounter a purple screen with questions about restarting services. Please make your selections accordingly < Yes >
After completing the MySQL installation, run a small script to set up the password for the database user.sudo mysql_secure_installation Answer the questions, set a password, and complete the database installation with the script.
Step 3 – install PHP Now going to install PHP.
Install the packages that enables PHP to communicate with the database sudo apt install php libapache2-mod-php php-mysql
By default, the webserver (Apache2) looks for an index.html page. Since we’re using PHP, let’s configure index.php as our default page. Open the dir.conf text file with the following commasudo nano /etc/apache2/mods-enabled/dir.conf
You should see the following text in the dir.conf file
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>Edit the file so it looks like this
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>Save the file with CTRL + O, press ENTER. Exit the file with CTRL + X, press ENTER.
After editing the file, restart the webserver (Apache2) to apply the new settings sudo systemctl restart apache2
Step 4 – Test PHP on your webserver With the web server, database, and PHP installed, we should be able to run a small PHP test
Create a new index.php file. sudo nano /var/www/html/index.php
Paste the following code into the file:
<?php
phpinfo();
?>Save the file with CTRL + O, press ENTER. Exit the file with CTRL + X, press ENTER.
Open your web browser and go to the IP address of your VPS. You should see a PHP page with information. If the page appears, your PHP modules are working.
Have any questions? Feel free to ask in the comments below!
