Create a famous workstation-create a PHP server on Ubuntu (Apache + PHP + MySQL)

Source: Internet
Author: User
Tags php server php and mysql

After consideration, I finally decided to configure PHP on Ubuntu. It turns out that configuring the PHP environment on Ubuntu is much simpler than that on sub-Windows.
System: ubuntu11.10

1. Install apache2
Sudo apt-Get install apache2
Then open it in Firefox:

Http: // localhost/

See it works !, The installation is successful.

Ii. Install PhP5
Sudo apt-Get install PhP5
Sudo/etc/init. d/apache2 restart

Test whether PhP5 is successfully installed.
Sudo gedit/var/www/testphp. php
Write in
<? PHP
Phpinfo ();
?>
Then open it in Firefox:

Http: // localhost/testphp. php

Default directory for ing:
Sudo ln-S/home/TAO/phptest/var/WWW
The ln command is used to create a non-same link for a file in another location;
The most common parameter of this command is-s, which means soft link. It is similar to the shortcut in Windows. The specific usage is the target file of the Ln-S source file.
If it is displayed normally, the installation is successful.
Iii. Install MySQL
Sudo apt-Get install mysql-Server

You will be prompted to enter the password.
MySQL only allows connections from the Local Machine (127.0.0.1). If you want to use multiple hosts or open them to the Internet, edit/etc/MySQL/My. CNF
Sudo gedit/etc/MySQL/My. CNF
Find
Bind-address = 127.0.0.1
Comment out with #, as shown in the following figure:
# Bind-address = 127.0.0.1
Log on to the terminal, MySQL-u root-P
Enter the password and then click OK.
4. Install MySQL Administrator
Sudo apt-Get install mysql-Admin
5. Install MySQL for Apache HTTP Server
Sudo apt-Get install libapache2-mod-auth-mysql
Sudo apt-Get install php5-mysql
Sudo apt-Get install phpMyAdmin

To make PHP and MySQL work together, Edit
Sudo gedit/etc/PhP5/apache2/PHP. ini
Uncomment; Extension = mysql. So, as shown in the following figure:
...
Extension = mysql. So
...

Sudo/etc/init. d/apache2 restart
Save the file and test the PHP link to MySQL.
Write in testphp. php
<? PHP
$ Con = mysql_connect ("localhost", "root", "your password ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}
Else
Echo "connectted! Oh year ~ "
// Some code

?>
If connectted is displayed! Oh year ~ The link is successfully linked.
6. Configure phpMyAdmin
Map the phpMyAdmin directory to the Apache directory and run the following command:

Sudo ln-S/usr/share/PHPmyAdmin/var/WWW
Then access http: // localhost/PHPmyAdmin/

If you write the code, you should use vim.
References:

Http://www.cnblogs.com/voidxy/archive/2009/08/07/1541210.html

Http://www.cnblogs.com/chenzhenianqing/archive/2011/08/08/2177112.html

Related Article

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.