Install the LAMP environment and phpMyAdmin using the command line in ubuntu

Source: Internet
Author: User
We must first install LAMP Apache, PHP5, and Mysql5. open the terminal and enter the command line. We need to install LAMP in Apache, PHP5, and Mysql5.

Open the terminal and enter the command line.

1. install Apache

sudo apt-get install apache2

2. test Apache

To determine whether the installation is successful, let's test it. Open your browser and enter the following URL:

Http: // localhost/

If It succeeds, you will see the following content: "It works! "Congratulations, the first step is that you are going out.

3. install PHP5

Step 1. open the terminal (ctrl + alt + T ).

Step 2. enter the following command line:

sudo apt-get install php5 libapache2-mod-php5

Step 3. to make PHP and Apache work together, we need to configure PHP and test it.

sudo /etc/init.d/apache2 restart

4. test PHP

Step 1. create a PHP Test File (phptest. php) and enter the following content:

sudo gedit /var/www/testphp.php

Step 2. we will open a text editor and enter the following content in it.

 

Step 3. save and exit.

Step 4. open the browser and check the content we just created. Enter the following URL:

http://localhost/testphp.php

If the PHP information page is displayed, it means that you have succeeded in a small step.

5. install MySQL

Next we will install Mysql5 (this is the last step, which is also a more troublesome step. pay attention to it during installation .)

Step 1. open the terminal again and enter the following content.

sudo apt-get install mysql-server

Step 2. during installation, enter the Mysql password if required. If no requirements are required, perform the next step. Enter the following command in the terminal:

mysql -u root

Later, you need to enter the following content;

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

The above 'root' is your Mysql User name, and 'yourpassword' is your new password.

Step 3. next we will deal with the more difficult phpmyadmin. the common problem here is that phpmyadmin is installed but the management interface is not displayed when http: // localhost/phpmyadmin is entered, the page is not found. Don't worry. we have installed phpmyadmin first and then solved it. Enter the following command:

Sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

Phpmyadmin here works with the php5 we installed earlier. if the PHP and phpmyadmin you installed do not match, they will not work.

Step 4. now let's solve the problem of "not working" phpmyadmin. after installing phpmyadmin, do not think everything is ready. In fact, we have another task to complete, that is, to configure phpmyadmin and apache2. For the same terminal, enter:

cp /etc/phpmyadmin/apache.conf /etc/apache2/sites-available/phpmyadmin

In this way, copy apache. conf (apache configuration file) in phpmyadmin to The phpmyadmin file under apache2/sites-available.

Step 5. enter the following information to go to the sites-enabled folder:

cd /etc/apache2/sites-enabled/

Step 6. after entering, we need to establish a link to the configuration file so that we can use it. Input:

sudo ln -s ../sites-available/phpmyadmin

Step 7. restart apache2

sudo /etc/init.d/apache2 restart

Okay. Open http: // localhost/phpmyadmin and try it out.

So far, our LAMP configuration has completely ended, and I hope it will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.