In order to facilitate their own study, from the csdn above the other people's article
sudo apt-get update
Install apache2: sudo apt-get install apache2 installation PHP module: sudo apt-get install php5 installation mysql s Udo Apt-get Install mysql-server other modules installation: sudo apt-get install libapache2-mod-php5 sudo apt-get instal L libapache2-mod-auth-mysql sudo apt-get install php5-mysql sudo apt-get install php5-gd The first two are easy to understand, to want a Pache can parse PHP, you need to use these two modules to find PHP engine. Third in PHP operation MySQL database use, most people have experience in database programming, so this does not have to explain the fourth GD library. APACHE2 related configuration After installing each of the above modules, in fact, the basic is OK, just a few small details of the problem basically a lot of configuration in the/etc/apache2 directory and its sub-directories, it is important to understand this directory structure. 1.apache root directory Install apache2, 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.PHP resolution problem installed after seemingly PHP parsing is a bit of a problem, browse PHP page will be saved, Apache did not parse it into a Web page. On the internet is generally said to need to add XXXX in the httpd.conf, for other Linux systems may be true, but Ubuntu is a bit special. Ubuntu Apache2 is configured in the/etc/apache2 directory. This directory has a apache2.conf file that contains all the APACHE2 system configuration information by including other configuration files. PHP parsing section in the configuration in/etc/apIn the ache2/mods-available php5.conf and Php5.load, the apache2.conf file did not include these two files, as long as they are included in the OK. ************************************************* found in apache2.conf # Include module configuration : include/etc/apache2/mods-enabled/*.load include/etc/apache2/mods-enabled/*.conf Add to the back include/etc/apache2/mods-available/php5.load include/etc/apache2/mods-available/php5.conf ********** Another way is to link these two files to the mods-enabled directory: sudo ln-s/etc/apache2/ mods-available/php5.load/etc/apache2/mods-enabled/php5.load sudo ln-s/etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php5.conf this way is a little better, without destroying the configuration structure of the apache2 itself. ************************************************* 3. Change the default directory of Apache2 to the current development directory apache2 default directory configuration in/etc The/apache2/sites-enabled/00default file. Find the DocumentRoot item in the file and change the/var/www to your development directory OK. Of course, there is one way to do this is not to have the default directory, just create a link to your directory under Var/www. For example your directory is in/home/username/phptest, then you just sudo ln-s/home/username/phptest/var/www/phptest so you can pass HTTP// Localhost/phptest has access to your working directory. [note] The link file name cannot contain ".", otherwise apache2 will attempt to parse it as a file and cannot reach the effect of the linked directory. Personal recommendation in the latter way, so that multiple working directories can be developed in parallel. Common commands in configuration Restart apache sudo/etc/init.d/apache2 restart to a simple test, create a new PHP file in the Phptest directory: test.php< ;! DOCTYPE html>
<title>php site</title>
<body>
<p>
<center>
<?php
echo "Hello,this is my first PHP webpage\n";
Phpinfo ();
?>
</center>
</p>
</body>
ubuntu14.04 Apache MySQL PHP environment setup