How to Install LAMP Stack
Overview & Objectives
This post features a walkthrough on how to install a LAMP stack on your Ubuntu machine
About LAMP Stack
LAMP Stack is a combination of open-source software that allows dynamic websites and web servers to function accordingly. LAMP is an acronym that stands for Linux, Apache, MySQL, and PHP. As developers, Linux is already installed since our virtual private server runs on Ubuntu. The below steps outline how to install the rest of the LAMP Stack in few easy steps.
You should have an active Alibaba Cloud account.
Installing LAMP Stack
Step 1: Launch Alibaba Cloud ECS instance for Linux machine
Alibaba Cloud ECS provides optimum support several instances. You can easily launch Alibaba Cloud ECS on your Linux machine. Follow the steps below to execute this application:
1.Login to your Alibaba Cloud ECS Management Console, where you will be redirected to the main dashboard.
2. Click Elastic Compute Service under the Products & Services section. This will take you to the ECS overview dashboard. Upon reaching that page click Instances on the sidebar to be navigate to the Instances menu.
3. Create an instance. Thereafter, you can select a preferred payment mode that suits your requirements. You can choose from two packages: Starter Package or Advanced Purchase. Make the appropriate selection for your data center region and Availability Zone to launch your ECS instance. If you are unsure of your Availability Zone, but you specify your data center region, then the instance will be placed in the default zone.
4. You will now have to select Generation under the Choose Instance Type section. Every generation type offers unique configuration and computing power. Select a Network Type from the options of Classic Network or VPC based on your requirements. Then, select a Network Billing type.
5. This will take you to the next page where you will have to opt for Ubuntu or any other Linux server by clicking one of the server thumbnails provided. Also, under the thumbnail, select a version for the server from the drop-down menu and pick the desired storage type from the various options.
6. You will next come to an option to set up your server’s security by setting a password. However, you may choose to complete this task later on your console.
7. Review the details of your purchase configuration, and make changes if needed. Click Activate to confirm and launch your server.
8. You will see your instances in the Instances section. Click Manage to manage the ECS instance.
9. Navigate to Security Groups from the left panel and select Configure Rules.
10. Check whether the instance is already set to allow inbound traffic from Port 80. If not, select Add Security Group Rules to create a new rule.
11. Enter the details as shown in the image below. Click OK to continue.
Step 2: Install Apache Server
Apache web server helps in accepting HTTP requests that come from browsers and allow them to serve them HTTP responses.
1. To install Apache, open terminal and enter the following commands:
apt-get install apache2
2. To verify successful installation, open your browser and hit the server IP as follows:
3. The Apache server default page should appear upon installation.
Step 3: Install MySQL
MySQL is the open source database management system used to store and management of the structured collection of data. It can store videos, pictures, and all other datatypes.
1. To install MySQL, open terminal and enter the following command:
sudo apt-get install mysql-server
Note: During installation, it will prompt to set the root user password. Set a password of your choice.
2. We can use the open source MySQL database management system or the Alibaba database management service called ApsaraDB for Relational Database System (RDS). Visit the tutorial on“How to Launch Apsara DB for RDS instance” to know more.
Step 4: Install PHP
PHP is an acronym that stands for Hypertext Preprocessor. It is an open source scripting language that aids web development and can be used with HTML.
1. To install PHP, open terminal and enter the following command:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt libapache2-mod-auth-mysql php5-mysql
libapache2-mod-php5 provides PHP5 module for the Apache 2 and is compatible only with Apache's prefork MPM.
php5-mcrypt enables the data encryption for added security reasons.
libapache2-mod-auth-mysql, an Apache 2 module that enables extra HTTP authentication for data stored in MySQL.
php5-mysql includes the generic "MySQL" module which can be used to connect to all versions of MySQL.
2. Answer yes to the prompts that follow, after which PHP will get installed. If you wish to serve the PHP pages with the Apache server, add PHP to the directory index. Open the file /etc/apache2/mods-enabled/dir.conf to facilitate this.
3. Add index.php at the beginning of index files, which looks like the following:
<IfModule mod_dir.c > DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule >
Step 5: Confirm Installation
To verify successful installation, deploy a sample PHP page with these configurations:
1. Create a new file. Name it: info.php in /var/www/html directory
2. Enter the following content in the file:
<?php phpinfo(); ?>
3. Save the file and exit.
4. Restart the Apache server to see the changes.
sudo service apache2 restart
5. Now, enter the server IP on the web browser:
LAMP Stack installation is now officially complete. LAMP stack is aptly touted as a very dynamic platform by developers across the globe. Also, it has proven as a secure, robust, and solid base to deploy high-performing web applications.
Related Alibaba Cloud Products Alibaba Cloud WAF, Alibaba CloudMonitor
Alibaba can add more layers to increase the reliability and security of our website in the production environment. We can also take backup by taking snapshots of our running database to eliminate database failure.
Alibaba Cloud Web Application Firewall (WAF) can be used to provide protection against web-based attacks, including SQL injections, Cross-site scripting (XSS), Malicious BOT, command execution vulnerabilities, and other common web attacks. WAF filters out a large number of malicious access attempts and alleviates the performance impact of Hypertext Transfer Protocol (HTTP)/HTTP Secure (HTTPS) flood attacks on servers.
Alibaba CloudMonitor can be used to provide in-depth insights into your cloud deployments. CloudMonitor provides advanced analytics on critical metrics such as Central Processing Unit (CPU) utilization, latency and also lets you customize parameters specific to business requirements.
Refer a Friend and Earn $20!Refer a Friend