Install and configure the Apache, MySql, and PHP environments in ubuntu

Source: Internet
Author: User

1: First install apache: open the terminal (ctrl + Alt + t ),


Enter the following command:


Sudo apt-get install apache2
To install,


After installation, open your browser and enter localhost or http: // 127.0.0.1 in the address bar.


If you see It works, the installation is successful!


Default root directory:

/Var/www/

2: install mysql:

 

After sudo apt-get install mysql-server is installed, you will be asked to set a new mysql root password, enter your own password, enter the key, and then confirm the password.


3: install PHP 5 and Apache PHP 5 module:

 

Sudo apt-get install php5 libapache2-mod-php5

Sudo/etc/init. d/apache2 restart (restart apache)
The attempt is successful. No:

Command:

Sudo gedit/var/www/text. php [create a text. php file under the default apache root directory/var/www]
Enter the following code in the text. Php file to check whether the installation is successful:


<? Php
Echo "helloworld ";
?>
In the browser address bar, enter:

Http: // localhost/text. php if helloworld is displayed on the page, the request is successful.

 

Tip: If you cannot enter the command again when you return to the terminal, press ctrl + z.


4. Make apache and php support mysql:


Sudo apt-get install libapache2-mod-auth-mysql
Sudo apt-get install php5-mysql
Sudo/etc/init. d/apache2 restart (restart apache)
Now the environment has been set up!

/Var/www/(put the apache2 webpage file here)

/Var/lib/mysql (put the mysql file here)

If you want to connect remotely, you need to install SSH with the command: sudo apt-get install ssh

Maybe we are still used to phpmyadmin.

5. Install phpmyadmin.


Sudo apt-get install phpmyadmin
Enter http: // localhost/phpmyadmin in the browser to find not found.

Therefore, you must transfer the installation to the phpmyadmin folder to/var/www/.


Sudo ln-s/usr/share/phpmyadmin // var/www/
Run the preceding command to transfer the phpmyadmin folder to the destination. Alternatively, you can copy phpmyadmin directly to the/var/www/folder.

When we enter http: // localhost/phpmyadmin in the browser again, we find that the interface we are familiar with is back.

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.