How to install PHP in Ubuntu

Source: Internet
Author: User
Tags install php phpmyadmin

How to install PHP in UbuntuSentiment Peacemaker | Browse 692 times posted on 2016-05-07 12:36Best Answer
About the lamp configuration steps under Ubuntu:

The first thing to install lamp is APACHE,PHP5,MYSQL5.

Open the terminal and enter the command line.
1. Installing Apache

1. Open the terminal

2. Enter the following command

sudo apt-get install apache2

3. If you do not have sudo permissions, you need to enter a password.
2. Test Apache

To determine if the installation was successful, test it.

1. Open the browser and enter the following URL

http://localhost/

If successful, you will see the following "It works!", congratulations, the first step is to cross out.
3. Installing PHP5

Step 1. Open Terminal (ctrl+alt+t).

Step 2. Enter the following command line:

sudo apt-get install php5 libapache2-mod-php5

Step 3. In order for PHP and Apache to work together, you need to configure PHP and test it.

Sudo/etc/init.d/apache2 restart
4. Test PHP

Step 1. First build a PHP test file (we call it phptest.php), enter the following:

sudo gedit/var/www/testphp.php

Step 2. A text editor opens, where you can enter the following content.

<?php phpinfo ();?>

Step 3. Save exit.

Step 4. Now open your browser and look at what you just created. Enter the following URL.

http://localhost/testphp.php
If you show PHP's information content page, you have another small step.

5. Install MySQL

Below to install MYSQL5 (this is the last step, but also a more troublesome step, the installation of attention. )

Step 1. To open the terminal again, enter the following content.

sudo apt-get install Mysql-server

Step 2. When installing, enter the password if the MySQL password is required. If there is no requirement, perform the next step. Enter the following command in the terminal.

Mysql-u Root

Later, you will also enter the following content;

mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' YourPassword ');
The above ' root ' is your MySQL username, ' YourPassword ' is your new password.

Step 3. The following is going to deal with the more difficult phpmyadmin here is often the problem is clearly installed phpmyadmin but in the input http://localhost/phpmyadmin, there is no management interface, but there is no page found. No hurry, first installed again phpMyAdmin and then to solve. Enter the following command:

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

The phpMyAdmin here is compatible with the previously loaded php5, and if you load PHP and phpMyAdmin do not match, they will not work.

Step 4. Now to solve the phpMyAdmin "not working" problem, when we installed phpMyAdmin, don't think everything is ready. In fact, there is a work to be done, is to configure phpMyAdmin and apache2. For the same terminal, enter:

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

This copies the apache.conf (Apache configuration file) in the phpMyAdmin to the phpMyAdmin file under Apache2/sites-available.

Step 5. Then enter it into the Sites-enabled folder:

cd/etc/apache2/sites-enabled/

Step 6. After entering, create a link to the configuration file so that it can be used. Input:

sudo ln-s. /sites-available/phpmyadmin

Step 7: Restart Apache2

Sudo/etc/init.d/apache2 restart

Finally, open the http://localhost/phpmyadmin to experience

How to install PHP in Ubuntu

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.