How To Install LAMP Stack On Debian 8

LAMP is a combination of operating system and open-source software stack. The acronym LAMP came from the first letters of Linux, Apache HTTP Server, MySQL or MariaDB database, and PHP/Perl/Python.

This tutorial describes how to install LAMP stack on Debian 8 64 bit server. The same steps will work on Debian 7 and all previous versions.

Install LAMP Stack On Debian

1. Install Apache

Apache is an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and virtual domains.

Switch to root user using command:

Then, install Apache web server using the following command:

Test Apache:

Open your web browser and navigate to http://localhost/ or http://server-ip-address/.

Apache2 Debian Default Page: It works - Mozilla Firefox_001

Voila! Apache web server is working!!

2. Install MySQL

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases, though SQLite probably has more total embedded deployments

During installation, you’ll be asked to setup the MySQL “root” user password. Enter the password and click Ok.

sk@debian: ~_002

Re-enter the password.

sk@debian: ~_003

MySQL is installed now.

You can verify the MySQL server status using command:

On Debian 8:

On Debian 7 and previous versions:

Sample output:

3. Install MariaDB

In case you want to use MariaDB instead of MySQL community edition, follow the steps given below.

MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.

First you have to remove existing MySQL packages if any. To completely uninstall MySQL along with its configuration files, enter the following commands one by one:


After removing MySQL, run the following command to install MariaDB.

Alternatively, you can install it using MariaDB repository if you want to try most recent version of MariaDB. Run the following commands to add PPA.

Update the software sources list and install MariaDB using following commands:

During installation you will be asked to set MariaDB ‘root’ user password. Enter the password twice, and complete the installation.

sk@debian: ~_004

Re-enter password:

sk@debian: ~_005

Check if mariadb is running or not, using the following command:

On Debian 8:

On Debian 7 and previous versions:

Sample output:

4. Install PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

To test PHP, create a sample “testphp.php” file in Apache document root folder.

Add the following lines.

Restart apache2 service.

On Debian 8:

On Debian 7 and previous versions:

Navigate to http://server-ip-address/testphp.php. It will display all the details about php such as version, build date and commands etc.

phpinfo() - Mozilla Firefox_006

If you want to install all php modules at once, enter the command apt-get install php* and restart the apache2 service. To verify the modules, open web browser and navigate to http://server-ip-address/testphp.php. You will able to see all installed php modules.

5. Manage MySQL Databases Using phpMyAdmin (Optional)

phpMyAdmin is a free open-source web interface tool used to manage your MySQL databases.

It is available in the Official Debian repositories.So install it with command:

Select the Web server that should be automatically configured to run phpMyAdmin. In my case, it is apache2.

sk@debian: ~_007

The phpMyAdmin must have a database installed and configured before it can be used. This can be optionally handled by dbconfig-common.

Select ‘Yes’ to configure database for phpmyadmin wjth dbconfig-common.

sk@debian: ~_008

Enter password of the database’s administrative user.

sk@debian: ~_009

Enter MySQL application password phpmyadmin.

sk@debian: ~_010

Re-enter the password.

sk@debian: ~_011

Success! phpMyAdmin installation is installed.

Additional Note: if you followed all steps carefully, phpMyAdmin should work just fine. In case phpMyAdmin is not working, please do the following steps.

Open terminal, and type:

Add the following line at the end.

Save and Exit. Restart apache service:

On Debian 8:

On Debian 7 and previous versions:

6. Access phpMyAdmin Web Console

Now, you can access the phpmyadmin console by navigating to http://server-ip-address/phpmyadmin/ from your browser.

Enter your MySQL username and password which you have given in previous steps. In my case its “root” and “debian”.

phpMyAdmin - Mozilla Firefox_012

You will be redirected to PhpMyAdmin main web interface. - localhost | phpMyAdmin 4.2.12deb2 - Mozilla Firefox_013

From now on, you can manage your MySQL databases from phpMyAdmin web interface.

That’s it. Your LAMP stack is ready to use.




未经允许不得转载:VPS啦 » How To Install LAMP Stack On Debian 8

赞 (0) 打赏