Firstly, before starting to provision our server, we should know and understand what Apache is.
The Apache service is a software program that runs on a server and provides web server functionality using the Apache HTTP Server software. Apache is one of the most widely used web servers in the world, and it powers many popular websites and web applications.
When you install and start the Apache service on a server, it listens for incoming web requests on port 80 (HTTP) and/or port 443 (HTTPS) and responds to those requests by serving up web pages and other content stored on the server’s file system. The Apache service can handle many types of web content, including HTMLfiles, images, videos, and more.
The Apache service also supports a wide range of features and configurations that can be customized to meet the needs of specific websites or web applications. For example, you can use Apache modules to add support for different programming languages, authentication methods, caching strategies, and more.
Overall, the Apache service is a critical component of many web hosting environments, and it plays an important role in delivering web content to users around the world.
Here are the steps to install and activate Apache on a Linux server:
Update the package repository by running the following command:
sudo apt update
Install Apache by running the following command:
sudo apt install apache2
Once the installation is complete, start the Apache service with the following command:
sudo systemctl start apache2
Verify that Apache is running by visiting your server’s public IP address in a web browser. If Apache is running, you should see the Apache default web page.
If you want Apache to start automatically whenever the server boots up, run the following command:
sudo systemctl enable apache2
Congratulations, you have successfully installed and activated Apache on your server
The 2nd step is the most important step in provisioning the web server, which is installing the (LAMP) stack:
LAMP stands for Linux, Apache, MySQL, and PHP. It’s a popular software stack used for hosting dynamic websites and web applications. Here are the steps to install LAMP on a Linux server:
Log in to your server using SSH.
Update the package repository by running the following command:
sudo apt update
Verify that Apache is running by visiting your server’s public IP address in a web browser. If Apache is running, you should see the Apache default web page.
4. Install MySQL by running the following command:
sudo apt install mysql-server
6. During the installation process, you’ll be prompted to set a password for the MySQL root user. Make sure to choose a strong password and keep it secure.
7. Once MySQL is installed, start the service with the following command:
sudo systemctl start mysql
8. Secure the MySQL installation by running the following command:
sudo mysql_secure_installation
9. Install PHP by running the following command:
sudo apt install php libapache2-mod-php php-mysql
10. Once the installation is complete, restart the Apache service with the following command:
sudo systemctl restart apache2
11. Test that PHP is working by creating a new file called info.php in the Apache web root directory:
sudo nano /var/www/html/info.php
12. Paste the following PHP code into the file:
<?php phpinfo(); ?>
13. Save and close the file.
14. Visit http://your_server_ip/info.php in a web browser. You should see a page displaying information about your PHP installation.
Congratulations! You have successfully installed LAMP on your server.