Install Apache2:
sudo apt-get install apache2
To install the PHP module:
sudo apt-get install php5
Install MySQL
sudo apt-get install Mysql-server
Other module installation:
sudo apt-get install LIBAPACHE2-MOD-PHP5
sudo apt-get install Libapache2-mod-auth-mysql
sudo apt-get install Php5-mysql
sudo 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 does not have to explain more
A fourth GD library.
Apache2 Related Configurations
After installing each of the above modules, the basic is actually OK, just a few minor details.
Basically, many configurations are done in the/etc/apache2 directory and its subdirectories, so be sure to figure out the directory structure.
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.PHP parsing problems
After installing the seemingly PHP parsing is a bit of a problem, browse PHP page will be saved, Apache did not parse it into a Web page.
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 under the/etc/apache2 directory.
There is a apache2.conf file in this directory that contains all the APACHE2 system configuration information by including other configuration files.
PHP parsing part of the configuration in the/etc/apache2/mods-available under the php5.conf and Php5.load, the apache2.conf file is not included in the two files, as long as the inclusion of the OK.
*************************************************
Found in apache2.conf
# Include Module Configuration:
Include/etc/apache2/mods-enabled/*.load
Include/etc/apache2/mods-enabled/*.conf
After which you add
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 is a better approach, without destroying the configuration structure of the apache2 itself.
*************************************************
3. 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 is not the default directory, just 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.
[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 referrals are made 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
For 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>
Save exit.
Open the browser, enter: localhost/phptest/tset.php, you can see the results of our PHP operation. Good luck! :-)
Publish PHP Project Personal Understanding:
The role of the ports.conf file under 1.apache
The file has The Listen field that determines the port number of the Apache project to default to a tomcat80 conflict So you can modify it to a different port number. For example here is modified for 8091.
2.sites-enabled file 000-default.conf file
This file is an Apache port processing file before we publish Apache Port as 8091 Port then use virtual host VirtualHost * : 8091来 accepts all 8091 port information DocumentRoot represents a webapps directory similar to Tomcat Apache The default project path is there.
3.apache2.conf
The file is Apache 's master profile equivalent to the conf/httpconfig of other Linux systems
In this file can be openedApacheof theRewriteSupport
<directory/>
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory/usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory/var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#<directory/srv/>
#Options Indexes FollowSymLinks
#AllowOverride All
#Require all granted
#</directory>
Build PHP and Apache environments under Ubuntu