Lamp (linux + apache + mysql + php) environment construction

Source: Internet
Author: User
Build a Lamp (linux + apache + mysql + php) environment

1. install apache2: sudo apt-get installapache2

After the installation is complete, run the following command to restart apache: sudo/etc/init. d/apache2 restart: enter http: // localhost or http: // 127.0.0.1 in the browser and you will see "It works! "Indicates that apache is successfully installed.

2. install php: sudoapt-get install libapache2-mod-php5 php5;

Install extension php5-gd: sudo apt-get installlibapache2-mod-php5 php5-gd

Php5-mysql: sudo apt-get install libapache2-mod-php5 php5-mysql

After installation, restart apache to load the PHP module: sudo/etc/init. d/apache2 restart.

Next, create a PHP file under the Web directory to test whether PHP can run normally:

Sudo gedit/var/www/phpinfo. php, input and save the file, and enter http: // localhost/phpinfo in the browser. php. if a page displays php running parameters, PHP can run normally.

Phpinfo ();

? Php>
3. install mysql: sudo apt-get installmysql-server mysql-client. enter the root password at the end of the installation. the root password here refers to setting the root password of MySQL.

4. install phpmyadmin-Mysql database management:

Sudo apt-get installlibapache2-mod-auth-mysql php5-mysql phpmyadmin, this installation with php5 phpmyadmin. After phpmyadmin is installed, configure phpmyadmin and apache2:

Cp/etc/phpmyadmin/apache. conf/etc/apache2/sites-available/phpmyadmin. copy the conf (apache configuration file) to The phpmyadmin file under apache2/sites-available, and enter the sites-enabled folder:

Cd/etc/apache2/sites-enabled to create a link to the configuration file: sudo ln-s .. /sites-available/phpmyadmin, restart apache2: sudo/etc/init. d/apache2restart. Finally, you can enable http: // localhost/phpmyadmin for verification. In this way, the basic components of LAMP are installed.

/*************************************** **************************************** */

Next, perform some other settings:

1. by default, the root directory of the PHP network server is set to/var/www. due to the security principle of the Linux system, only the root user can perform operations to change the file read/write permissions under the Directory, therefore, you can use the root terminal command: sudo chmod 777/var/www to modify the read and write permissions of the/var/www directory, and then you can write the html or php file.

2. configure apahce: enable the mod_rewrite module sudo a2enmod rewrite and restart the apache server sudo/etc/init. d/apache2 restart: create the file test in the/var/www directory. php, write code Save and enter http: // 127.0.0.1/test. php in the browser. if the php configuration information appears, it indicates that LAMP Apache is working properly (restart the apache server and test ).

Set apacheto support .htm. html. php: sudo gedit/etc/apache2/apache2.conf

Add AddType application/x-httpd-php. php. htm. html to the open file.

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.