Install the lamp environment and configure the ubuntu system

Source: Internet
Author: User
This article describes how to install the lamp environment and configure the ubuntu system. For more information, see LAMPUbuntu.

Install LAMP quickly in ubuntu

1. install

Enter the command directly on the terminal:

Copy codeThe code is as follows:
Sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql

Enter the root password as prompted. after the command is executed, both apache mysql and php are installed.

2. change file permissions

After LAMP is installed, the default root directory of the PHP network server is/var/www. Due to the security principles of the Linux system, the file read and write permissions under this directory only allow the root user to operate. Therefore, we cannot create or modify or delete php files in the www folder, you must first modify the read and write permissions of the/var/www directory. You cannot modify the file permission by right-clicking the attribute in the interface manager. you must run the root terminal command: sudo chmod 777/var/www. Then you can write html or PHP files.

3. install phpmyadmin

Enter the following command on the terminal:

Copy codeThe code is as follows:
Sudo apt-get install phpmyadmin

Follow the prompts to enter the password and start the download and installation. During the installation process, you must select Web server: apache2 or lighttpd, select apache2, press the tab key, and click OK. Then, you are required to enter the Mysql database Password of the database's administrative user. Then, establish a connection between phpmyadmin and apache2. take my example: the www directory is in the/var/www directory, and The phpmyadmin directory is in the/usr/share/phpmyadmin Directory. Therefore, run the following command: connect sudo ln-s/usr/share/phpmyadmin/var/www.

Phpmyadmin test: open http: // localhost/phpmyadmin in the address bar of the browser. Check whether phpmyadmin is successfully installed.

4. apachesupports .htm. html. php

Open the apache configuration file:

Copy codeThe code is as follows:
Sudo vim/etc/apache2/apache2.conf

Add any row in this file:

Copy codeThe code is as follows:
AddType application/x-httpd-php. php. htm. html

5. modify the default apache2 encoding.

Open the apache configuration file:

Copy codeThe code is as follows:
Sudo vim/etc/apache2/apache2.conf

Add:

Copy codeThe code is as follows:
Adddefacharcharset UTF-8

Note: Each time you modify the apache configuration file, you must restart apache to make it take effect. The command to restart apache is:

Copy codeThe code is as follows:
Sudo/etc/init. d/apache2 restart

Several terminal commands frequently used by LAMP components

Copy codeThe code is as follows:
Restart apache: sudo/etc/init. d/apache2 restart
Restart mysql: sudo/etc/init. d/mysql restart
Configure php. ini: sudo gedit/etc/php5/apache2/php. ini
Configure apache2.conf: sudo gedit/etc/apache2/apache2.conf
Configure my. cnf: sudo gedit/etc/mysql/my. cnf
Php cgi: sudo/var/www/cgi-bin/

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.