How 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.
- 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:
- echo "php phpinfo(); ?>" | sudo tee /var/www/testing.php
After that, you need to restart the Apache web server.
- 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.
- apache2: Could not reliably determine the server's fully qualified domain
- 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.
- echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn
Now, reload the Apache web server.
- 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.
- cat /etc/hosts | grep localhost
You should see something like this:
- 127.0.0.1 localhost
- ::1 ip6-localhost ip6-loopback
Now you should confirm that you have the correct bind address in your MySQL my.cnf file.
- cat /etc/mysql/my.cnf | grep bind-address
You should see:
- 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:
- 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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

To delete an extra ServerName directive from Apache, you can take the following steps: Identify and delete the extra ServerName directive. Restart Apache to make the changes take effect. Check the configuration file to verify changes. Test the server to make sure the problem is resolved.

This article will explain how to improve website performance by analyzing Apache logs under the Debian system. 1. Log Analysis Basics Apache log records the detailed information of all HTTP requests, including IP address, timestamp, request URL, HTTP method and response code. In Debian systems, these logs are usually located in the /var/log/apache2/access.log and /var/log/apache2/error.log directories. Understanding the log structure is the first step in effective analysis. 2. Log analysis tool You can use a variety of tools to analyze Apache logs: Command line tools: grep, awk, sed and other command line tools.

This article introduces several methods to check the OpenSSL configuration of the Debian system to help you quickly grasp the security status of the system. 1. Confirm the OpenSSL version First, verify whether OpenSSL has been installed and version information. Enter the following command in the terminal: If opensslversion is not installed, the system will prompt an error. 2. View the configuration file. The main configuration file of OpenSSL is usually located in /etc/ssl/openssl.cnf. You can use a text editor (such as nano) to view: sudonano/etc/ssl/openssl.cnf This file contains important configuration information such as key, certificate path, and encryption algorithm. 3. Utilize OPE

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.

There are 3 ways to view the version on the Apache server: via the command line (apachectl -v or apache2ctl -v), check the server status page (http://<server IP or domain name>/server-status), or view the Apache configuration file (ServerVersion: Apache/<version number>).

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.
