VPS & Dedicated Servers (Hosting Control Center) Help

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:

# yum install httpd

Start the Apache service with the following command:

# service httpd start

Configure the Apache service to start automatically when you boot your server by using the following command:

# chkconfig httpd on

Verify the Apache server is running by pointing your web browser to localhost.

Set up MySQL

Install MySQL with the following command:

# yum install mysql-server

Start the MySQL service with this command:

# service mysqld start

Configure the MySQL service to start automatically when you boot your server by using the following command:

# chkconfig mysqld on

Secure your installation of MySQL with the following command:

# /usr/bin/mysql_secure_installation

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:

# yum install php php-mysql

Create the file /var/www/html/info.php with the following line:

&lt?php phpinfo();?&gt

Restart the Apache server with the following command:

service httpd restart

Point your web browser to localhost/info.php. IIf PHP has been properly installed, you'll see a table of system information.

Was This Article Helpful?

Thanks for your feedback. To speak with a customer service representative, please use the support phone number or chat option above.

Glad we helped! Anything more we can do for you?

Sorry about that. Tell us what was confusing or why the solution didn’t solve your problem.