fbpx

How to setup LAMP Stack on Debian 10/Ubuntu 18.04

How to setup LAMP Stack on Debian 10/Ubuntu 18.04

Default Article Image Vulr Banner

Choosing Debian 10 and Ubuntu 18.04 LAMP for your webserver is a solid choice! Each of these these operating systems have been around for years!

Not Using Debian 10 or Ubuntu 18.04? Check out our other articles on other operating systems!

CentOS 7CentOS 8
RHEL 7RHEL 8

Step 1: Update All Software Packages

Before setting up LAMP it’s generally a good idea to update all of the repositories and software packages.

sudo -s

sudo update update -y

Step 2: Install and setup Apache (HTTPD)

apt install httpd httpd httpd-tools php-mysqlnd php-fpm mariadb-server -y

Optional packages to install to make future management easier

apt install nano wget git net-tools -y

Next we need to enable the HTTPD service we just installed

systemctl start httpd
systemctl enable httpd

Next check the status of the HTTPD service

systemctl status httpd

Output (press Q once you verify your service is running)

Next we will need to allow HTTP and HTTPS through the firewall

 sudo ufw allow in "WWW Full" 

Now we need to configure permissions

chown -R apache:apache /var/www/html/*
chcon -t httpd_sys_rw_content_t /var/www/html/ -R

Step 3: Setup MySQL (MariaDB)

systemctl start mariadb
systemctl enable mariadb

Check to make sure the service is running

systemctl status mariadb

Next we need to configure MySQL by setting up a root password and securing it.

mysql_secure_installation

Since this is a fresh configuration there will be no MySQL root password so simply press enter and set one. Once a password is set you can simply press enter through the rest of the configuration


Step 4: Test Installation

Navigate to the IP/Domain of your server and ensure it is online. Additionally, you can follow the steps below to test your PHP setup.

To test your PHP setup create a file at /var/www/html/info.php and place the following in the file.

 <?php phpinfo(); ?> 

Once the file is created navigate to the website URL /info.php and ensure the service is working properly. Once you have verified this you must remove this file.

Done! Congratulations you have completed the LAMP setup for CentOS 8. Future tutorials will walk you through hosting multiple websites on a single CentOS 8 instance and much more! Choosing Debian 10 and Ubuntu 18.04 LAMP for your webserver is a solid choice! Each of these these operating systems have been around for years!

Some of the links in this article are "affiliate links", a link with a special tracking code. This means if you click on an affiliate link and purchase the item, we will receive an affiliate commission. The price of the item is the same whether it is an affiliate link or not. Regardless, we only recommend products or services we believe will add value to our readers. By using the affiliate links, you are helping support our Website, and we genuinely appreciate your support.

 

Leave a Reply