The main packages required to run a web application on a Linux server will be Apache, MySQL, PHP and commonly known as LAMP (Linux, Apache, Mysql, PHP). A Linux OS will be installed on your server (in this example, Ubuntu Server). Apache is the web server. MySQL is the database administration system. The PHP package servers the PHP content on the web application. Let’s have a look at how we can install LAMP on an Ubuntu server.

STEP #1:

Log in to the server and switch to root/log in as root.

STEP #2:

Update the system to the latest. Run the below command.

apt update
apt upgrade

STEP #3:

Install the tasksel package, which helps to install multiple packages at the same time. It’s a quick way of installing.

apt install tasksel -y

STEP #4:

Install LAMP using tasksel

tasksel install lamp-server

Tasksel has a predefined lamp package and is quite easy to install. Just choose the lamp server by keyboard inputs and install it.

STEP #5:

Secure the mysql using below command. It helps to configure additional security.

mysql_secure_installation

STEP #6:

Time to verify all services are running fine.

netstat -ntlp

The above installation utilizes the tasksel tool. There is another method where everything needs to be installed separately.

Apache can be installed using the below command:

apt install apache2 -y

Mysql installation command is:

apt install mysql-server -y

PHP needs to be installed using below command

apt install php libapache2-mod-php php-mysql

STEP #7:

To ensure the apache has been installed, do load the http://serverip on web browser, this should show a Ubuntu default page.

STEP #8:

The apache virtualhost needs to be configured accordingly. In this example, we will utilize: /etc/apache2/sites-available/racknerd.local.conf

A sample directive has been added below:

<Directory /var/www/html/racknerd.local/public>

Require all granted

</Directory>

<VirtualHost *:80>

ServerName racknerd.local

ServerAlias www.racknerd.local

ServerAdmin racknerd@localhost

DocumentRoot /var/www/html/racknerdlocal/public

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Check the apache syntax using below command and it show no syntax error.

httpd -t

Just reload apache


systemctl reload apache2

You can set a simple phpinfo page in document root and test it on browser using http://serverip/info.php it will show PHP info and thus ensure the web server setup is successful and running.

Server Hosting Solutions by RackNerd:

Shared Hosting
cPanel Web Hosting in US, Europe, and Asia datacenters
Logo
Reseller Hosting
Create your new income stream today with a reseller account
Logo
VPS (Virtual Private Server)
Fast and Affordable VPS services - Instantly Deployed
Logo
Dedicated Servers
Bare-metal servers, ideal for the performance-demanding use case.
Logo

Leave a comment

Your email address will not be published. Required fields are marked *