Configure the LAMP environment on Ubuntu

Source: Internet
Author: User

Configure the LAMP environment on Ubuntu
The configuration of the LAMP environment is divided into three parts: installation, configuration and testing.
1. Install
Install Apachesudo apt-get install apache2
After Apache2 is installed, a new www directory/var/www/will be created/
Install MySQL
Sudo apt-get install mysql-server mysql-client
During installation, the system prompts you to enter the root user password.
Install PHP
Sudo apt-get install php5 libapache2-mod-php5
After installation, restart Apache to load the php module.
Sudo/etc/ini. d/apache2 restart

2. Configuration

(The following configuration file is opened by using vim or another text editor)
Configure Apachesudo vim/etc/apache2/apache2.conf
Open the configuration file and add the content at the end of the document.
First, add type support
AddType application/x-httpd-php. php. html. htm
Then, add the default character set as needed.
Adddefacharcharset UTF-8
Then, add the access sequence of the home page files as needed. The previous access sequence takes precedence.
<IfModule dir_module>
DirectoryIndex index.htm index.html index. php
</IfModule>
Finally, modify the default path of Apache (that is, the www directory)
Open related configuration files
Sudo vim/etc/apache2/sites-enabled/000-default.conf
Find DocumentRoot/var/www/html
Change to DocumentRoot/var/www
Restart apache to make the configuration take effect.
Sudo/etc/init. d/apache2 restart

3. Test
Test Apache
Always open ingress in the browser
Test MySQL
Total input at the terminal
Sudo netstat-tap | grep mysql
If you can see the words tcp 0 0 localhost: mysql 1060/mysqld, the configuration is successful.
If not, restart mysqlsudo/etc/init. d/mysql restart.
Test PHP
First, modify the permissions of the www directory.
Sudo chmod-R 777/var/www
Create a test. php test file in the www directory.
Cd/var/www
Sudo touch test. php
Sudo vim test. php
Then write the following code in the test file to call a phpinfo () function.
<? Php
Phpinfo ();
?>
After saving it, browse localhost/test. php In the browser. If you can see a page showing the php parameter amount, it indicates that the php configuration is successful.

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.