How to build PHP running environment under Ubuntu server _linux

Source: Internet
Author: User
Tags php and mysql
This article mainly introduces the Ubuntu server to build PHP operating environment method, simple analysis of the Ubuntu operating system environment to build Apache, PHP and MySQL module related steps, commands and operating skills, the need for friends can refer to the next

This paper describes the way to build PHP running environment under Ubuntu Server. Share to everyone for your reference, as follows:

Install Apache2:


sudo apt-get install apache2


To install the PHP module:


sudo apt-get install php5


Install MySQL


sudo apt-get installmysql-server


Other module installation:


sudo apt-get install Libapache2-mod-php5sudo apt-get installlibapache2-mod-auth-mysqlsudo apt-get Installphp5-mysqlsudo Apt-get Install PHP5-GD


The first two are easy to understand, in order for Apache to parse PHP, you need to use these two modules to find PHP engine. The third is used in PHP to operate the MySQL database, most people have experience in database programming, so this is not much to explain. A fourth GD library.

1.apache root directory

After installing apache2, the root directory under/VAR/WWW, you can test it by http://localhost/ . Of course, you can also create a new file in this directory test.html to try http://localhost/test.html.

2. Change the default directory of Apache2 to the current development directory

The default directory for APACHE2 is configured in the /etc/apache2/sites-enabled/00default file.

Locate the DocumentRoot entry in the file, and change the/var/www to your development directory for OK.

Of course, there is another way to do this is not to change the default directory, but to create a link to your directory under Var/www. For example, your directory is in /home/username/phptest, so you just


sudo ln-s/home/username/phptest/var/www/phptest


This way you can access your working directory through Http://localhost/phptest .

3. Common commands in configuration

Restart Apache


Sudo/etc/init.d/apache2 restart
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.