How to set up a LAMP stack
A Linux, Apache, MySQL and PHP (LAMP) stack is a model for a web server software solution. Linux is an operating system, Apache is an HTTP server, MySQL is a database and PHP is a programming language. LAMP is available for most Linux distributions, and is commonly used in web servers to build web applications and dynamic websites. Assuming your server is already running a Linux-based operating system such as CentOS, setting up a LAMP stack primarily consists of installing Apache, MySQL and PHP, if those components are not already in place.
|DIFFICULTY strong>||Basic - 1 | Medium - 2 | Advanced - 3|
|TIME REQUIRED strong>||30 min|
|RELATED PRODUCTS strong>||CentOS-based VPS or dedicated servers|
Here is a quick tutorial on how to set up a LAMP stack. This procedure requires you to have root privileges. (Some of these components may already be installed in your environment; this tutorial is appropriate if you have to install all of these components.) You will need to be logged in as root to complete this tutorial.
Set up Apache
Install Apache by executing the following yum command from a terminal window:
Start the Apache service with the following command:
Configure the Apache service to start automatically when you boot your server by using the following command:
Verify the Apache server is running by pointing your web browser to localhost.
Set up MySQL
Install MySQL with the following command:
Start the MySQL service with this command:
Configure the MySQL service to start automatically when you boot your server by using the following command:
Secure your installation of MySQL with the following command:
You will be prompted for MySQL's root password. This account doesn't have a password since you've just installed MySQL, so just press Enter. Answer Y when prompted to set the root password, and follow the instructions. Choose the default value of Y for the remaining questions. The installation process will reload MySQL to implement your changes.
Set up PHP
Install php with the following command:
Create the file /var/www/html/info.php with the following line:
Restart the Apache server with the following command:
Point your web browser to localhost/info.php. If PHP has been properly installed, the info.php