Setting up a LAMP Stack (Linux, Apache, MySQL, PHP)

1. Install Apache
2. Install MySQL
3. Install PHP
4. Verify LAMP Stack

1. Install Apache

Install the package:
Debian/Ubuntu

sudo apt-get install apache2

Fedora/CentOS/SUSE Systems

yum install httpd

And start the service:

sudo service apache2 start

or

sudo service httpd start

 

2. Install MySQL

Debian/Ubuntu

$ sudo apt-get install mysql-server
$ sudo mysql_secure_installation
$ sudo mysql_install_db

$ sudo service mysql start

CentOS/Fedora/SUSE

$ sudo yum install mysql-server
$ sudo service mysqld start
$ sudo /usr/bin/mysql_secure_installation

The mysql_secure_installation command runs the setup for MySQL.

This allows you to set up a root password, and a few other configuration options.

3. Install PHP

Debian

sudo apt-get install php5 libapache2-mod-php5

CentOS/Fedora/SUSE

sudo yum install php php-mysql

4. Verify LAMP Stack

You can verify your Apache installation by visiting http://localhost in your browser.

If installed correctly, and the service is running, you will see a message saying “It works!”

lamp stack apache-it-works

To verify your PHP installation, create the following file:

sudo vim /var/www/html/info.php

and add this line:

<?php phpinfo(); ?>

Now navigate to http://localhost/info.php. You should see a page displaying all of the configuration information for PHP on your system.

lamp stack phpinfo

That’s it!

If you do encounter any errors, your best bet is to Google that shit!

Chances are high that question has been asked and answered on Stack Overflow.

Thanks for reading!

/kimberly

Syntax Highlighting by EnlighterJS

About the Author

Kimberly is a software engineer, and currently works as a Test Engineering Intern for Mozilla.

While she always enjoys learning new technologies, her current focus is python, and when she has free time (she doesn't), Angular & Node.

When not coding, Kimberly spends time with her three young boys in Durango, CO.


One Reply to “Setting up a LAMP Stack (Linux, Apache, MySQL, PHP)”

Comments are closed.