search
HomeBackend DevelopmentPHP TutorialHow to install LAMP server system on Ubuntu?

Why should you install LAMP server on Ubuntu? When working in web development, I prefer to develop in a development environment on my own computer without distractions. I'd rather make most of my mistakes invisible to others than have them all visible to everyone on the internet. In order to have such a private development environment, I installed a LAMP system. By the way, if you're not familiar with LAMP, it stands for Linux, Apache, MySQL and PHP (and/or Perl). LAMP is one of the most common web hosting platforms on the Internet, so it is one of the excellent environments for building and testing websites.

Follow these step-by-step instructions below to install and configure LAMP on Ubuntu 12.04 (Precise Pangolin). This process has also been tested on Linux Mint 13/14/15, Ubuntu 12.10 (Quantal Quetzal) and Ubuntu 13.04 Raring Ringtail. If you have a reasonably fast broadband connection, it should take less than half an hour.

Install LAMP on Ubuntu

The developers of Ubuntu have made it easy for people to install and configure LAMP packages with the help of a single terminal command. So, open a terminal window and let’s get started.

  1. sudo apt-get install lamp-server^ 

Yes, you read that right. Don't miss the caret (^) at the end. Without the caret, the command will not run. It's so magical!

Installing LAMP on Ubuntu

apt package manager now displays packages that need to be installed and are waiting for confirmation. Enter the Enter key to confirm and continue the installation.

Install the LAMP package

After it takes a while to download the package, you will be prompted to set a password for the MySQL root user.

Set MySQL Root Password

Enter the password you want to use for MySQL. This cannot be left empty. You will be prompted to enter it a second time to confirm your password.

Confirm MySQL root password

After confirming the password, apt will continue to install the remaining packages.

Installation of remaining LAMP packages

Your LAMP installation is now complete. Wow, it’s that simple! Now there are only a few steps left to configure so that you can use the system easily.

Testing Apache

Open a web browser window and enter the address http://localhost/. You should see a web page that says "It Works!".

Apache is working properly

Test php

You have confirmed that the Apache web server is working properly, so you should make sure that the installed php is working properly. To do this, you need to create a file called testing.php in /var/www. You can use a common text editor as the root user, or you can use the following terminal command:

  1. echo "php phpinfo(); ?>" | sudo tee /var/www/testing.php 

After that, you need to restart the Apache web server.

  1. sudo service apache2 restart 

Go back to your web browser and enter the address http://localhost/testing.php/, you should see a web page showing information about the installed php.

php information

Getting the Apache fully qualified domain name

You may have noticed an error message from Apache that is related to the fully qualified domain name of the server.

  1. apache2: Could not reliably determine the server's fully qualified domain 
  2. name, using 127.0.1.1 for ServerName 

This is not a big problem, but if it annoys you, you can use the following command to fix it.

  1. echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn 

Now, reload the Apache web server.

  1. sudo service apache2 reload 

You should never see this error message again.

Configuring MySQL

Since this tutorial aims to set up a local web development environment, you need to bind MySQL to the local host IP address. By default, this address should be 127.0.0.1 on your system. Just in case, you can use these commands to confirm the address.

  1. cat /etc/hosts | grep localhost 

You should see something like this:

  1. 127.0.0.1 localhost 
  2. ::1     ip6-localhost ip6-loopback 

Now you should confirm that you have the correct bind address in your MySQL my.cnf file.

  1. cat /etc/mysql/my.cnf | grep bind-address 

You should see:

  1. bind-address = 127.0.0.1 

If the bind address does not match the one set for localhost on your system, you will need to edit /etc/mysql/my.cnf as root to correct it .

Install phpMyAdmin

You don’t need to install phpMyAdmin, but unless you are a wizard with SQL, you will need it to handle administrative tasks on your MySQL database.

You can use this terminal command to install phpMyAdmin:

  1. sudo apt-get install libapache2-mod-auth-mysql phpmyadmin 

You will be prompted to confirm that you want to install the package. Press Enter to continue.

Install the phpMyAdmin package

You will then be prompted to select the web server configured for phpMyAdmin. This is important! Using the arrow keys on your keyboard, highlight apache2, then use the space space to select it. Then press Enter to continue. Make sure to click on the image below to zoom in and see what I'm describing.

Configuring phpMyAdmin for Apache

The next screen will ask you if you want to configure a database called dbconfig-common for phpMyAdmin. Select "Yes" and press Enter.

Configure dbconfig-common for phpMyAdmin

Next, you will be prompted to enter the MySQL root password you set before, so that you can create a new database. So, enter your MySQL root password and press Enter.

Enter the MySQL root password

The next tip is to create a MySQL application password for phpMyAdmin. If you want to create a random password, press Enter. I usually use the same password I use for the MySQL root password. This may not be the best approach from a security perspective, but since this is for a closed development environment the risk is likely to be minimal.

phpMyAdmin MySQL Application Password

Finally, you will be prompted to confirm the MySQL application password. Enter the same password as in the previous step and press Enter.

Confirm MySQL application password

At this point, the installation and configuration of phpMyAdmin is complete.

Test phpMyAdmin

The last step is to make sure phpMyAdmin is running normally. Open a web browser and enter the address http://localhost/phpmyadmin/. You should see a page like this.

phpMyAdmin login screen

Now you should be able to log in with the username root and the root password you created earlier.

phpMyAdmin logged in

Congratulations, now you have completed the installation and configuration of LAMP and phpMyAdmin on Ubuntu 12.04. Now, you can start creating your local website. If you are just developing a website, you can put the files into /var/www. Please note: /var/www is owned by user and group root, so you will need to copy the files there as root, or change the ownership and/or permissions of the directory so that you can write files there. Alternatively, you can do some additional Apache configuration that will keep the files somewhere in your home directory. You can even build multiple websites that way.

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces how to install the LAMP server system on Ubuntu? , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools