PHP (1): Build a LAMP Development Environment

Source: Internet
Author: User
Refer to: hi. baidu. comdabutianxiaitem2065e6a50dbb0ff614329b43 1. installation 1. Apache installation Introduction: ApacheHTTPServer is the world's top Web server software. It can run in almost all $ sudoapt-getinstallapache2Apache a new directory is created during installation: v

Reference: http://hi.baidu.com/dabutianxia/item/2065e6a50dbb0ff614329b43 1, installation 1. install Apache Introduction: Apache HTTP Server is the world's top Web Server software. It can run in almost all $ sudo apt-get install apache2 Apache will create a new directory during installation:/v

Reference: http://hi.baidu.com/dabutianxia/item/2065e6a50dbb0ff614329b43


I. Installation
1. install Apache
Overview: Apache HTTP Server is the world's top Web Server software. It can run in almost all

$ Sudo apt-get install apache2

During installation, Apache creates a directory:/var/www, which is the root directory for storing documents on the server. In addition, there is a file index.html under/var/www. at this time, you enter 127.0.0.1in the address bar of the firefox browser that comes with Ubuntu, and you can open index.html. You can give it a try.

2. Install MySQL
Brief Introduction: MySQL is an open-source small-scale associated database management system. The developer is MySQL AB in Sweden. MySQL is widely used in small and medium websites on the Internet. Because of its small size, fast speed, and low total cost of ownership, especially the open source code, many small and medium websites have chosen MySQL as their website database to reduce their total cost of ownership.

$ Sudo apt-get install mysql-server-5.5 mysql-client-5.5

At the end of the installation, the system will prompt you to enter the mysql root Password.

3. install PHP
Introduction: PHP (abbreviation of PHP: Hypertext Preprocessor, Chinese name: "PHP: Hypertext Preprocessor") is a common open source scripting language. The syntax absorbs the features of C language, Java, and Perl. It has a low entry threshold, is easy to learn, and is widely used. It is mainly applicable to the Web development field. The suffix of the PHP file is *. php.

$ Sudo apt-get install php5 libapache2-mod-php5

Restart Apache to load the PHP module.
Sudo/etc/init. d/apache2 restart


4. Install phpMyAdmin
Brief Introduction: phpMyAdmin is a PHP-based MySQL database management tool built on the website host in the Web-Base mode, allowing managers to use Web interfaces to manage MySQL databases. By using this Web interface, you can become a better way to easily input complicated SQL syntax, especially to process the import and export of a large amount of data. One of the biggest advantages is that phpMyAdmin runs on the Web server like other PHP programs, but you can use the HTML pages generated by these programs anywhere, that is, remote management of MySQL databases, allows you to easily create, modify, and delete databases and data tables. You can also use phpMyAdmin to create common php syntaxes to facilitate the correctness of the SQL syntaxes required for compiling webpages.

$ Sudo apt-get install phpmyadmin

During installation, you will be prompted to create a new database. You can choose either or not to install the database.


But as a newbie like me, you must select OK.


Ii. Configuration 1. Configure Apache
$ Sudo gedit/etc/apache2/apache2.conf at the end of the document,

Supported file types: AddType application/x-httpd-php. php. html. htm

(Depending on your needs) default Character Set: AddDefaultCharset UFT-8

(As needed) You can add three homepage files in the order of first access priority:

DirectoryIndex index.htm index.html index. php


After the configuration is complete, restart apache to take effect: sudo/etc/init. d/apache2 restart

In this case, the default apache folder is/var/www. If you want to change it to/home/hwh/www

You need to do this:

$ Sudo gedit/etc/apache2/sites-available/default

Change all/var/www in the default file to/home/hwh/www


2. Configure PHP5
$ Sudo gedit/etc/php5/apache2/php. ini

Set
; Date. timezone =
Change
Date. timezone = PRC

3. Configure mysql
Code: $ sudo gedit/etc/mysql/my. cnf

By default, only local access to the database is allowed. If you need access from other machines, comment out this sentence #.
Bind-address 127.0.0.1

4. Configure phpmyadmin

Phpmyadmin is not installed under/var/www by default, but under/usr/share/phpmyadmin. You can copy phpmyadmin to/var/www.
Code: $ sudo cp-r/usr/share/phpmyadmin/var/www/phpmyadmin
Then run:
Sudo gedit/etc/phpmyadmin/apache. conf

Change the/usr/share/phpmyadmin path in the following two sentences to/var/www/phpmyadmin
Alias/phpmyadmin/usr/share/phpmyadmin




Iii. Test

1. Test Apache

Enter http: // localhost/to check whether the words It works appear.


2. Test MySQL

Input: sudo netstat-tap | grep mysql

You can see rows similar to the following:
Hwh @ Mountain :~ $ Sudo netstat-tap | grep mysql
Tcp 0 0 localhost: mysql *: * LISTEN 8939/mysqld
If the server cannot run properly, run the following command to start it: sudo/etc/init. d/mysql restart

3. Test PHP
The Apache root directory installed in Ubuntu is located in/var/www.
Add a test file test. php to the file,
Content:
Phpinfo ();
?>
The browser re-enters http: // localhost/test. php. If a page displays PHP running parameters, PHP is running properly.


4. Test phpmyadmin

Enter http: // localhost/phpmyadmin in the browser. The access instructions are configured. Use root as the user name and the password entered during phpmyadmin installation as the password. log on to phpmyadmin. At this time, you can freely create databases and database users.

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.