1, installation apache2
sudo apt-get install apache2
Run the following command restart: sudo/etc/init.d/apache2 restart
Enter http://localhost or http://127.0.0.1 in the browser, if you see the IT works!, it means that Apache is installed successfully.
===================================================================
If you don't see it works! at this point do not worry, please see the following solution:
It should be stated that the generic Apache release configuration file is:
httpd.conf
The main configuration file for the Ubuntu release is:
/etc/apache2/apache2.conf
So, if you see someone else configuring httpd.conf, but you're not, it's normal!
If you don't have See it works! Then Modify /etc/apache2/apache2.conf, add a line of content:ServerName 127.0.0.1:80
Apache2 Some of the commonly used commands
The resulting start and stop files are:/etc/init.d/apache2
Configuration file is:/etc/apache2/apache2.conf
Start: sudo apache2ctl-k start
Stop: sudo apache2ctl-k stop
Restart: sudo apache2ctl-k restart
===================================================================
after the installation of Apache will be returned under/var a directory called WWW, there is an HTML folder, which is the default Web directory Apache , due to the security principle of Linux system, the file read and write permission in the directory is only allowed root user operation, so we can not create a new php file in the WWW folder, can not be modified and deleted, you must first modify the/var/www directory read and Write permissions, execute the command: sudo chmod 777/var/www
2. Install PHP
sudo apt-get install libapache2-mod-php5 php5
after installation, we will restart Apache and let it load the PHP module:
Sudo/etc/init.d/apache2 restart
3. Testing
You can now test whether PHP works correctly by creating a new test.php file under the Web directory:
sudo vim/var/www/test.php
Then enter: <?php echo "hello,world!!";? >
Then save the file, enter the http://127.0.0.1/test.php in the browser, if the hello,world!! is displayed in the Web page, it means that PHP is working properly.
===================================================================
more installation methods can be seen here , but I haven't tried ...
more about apache configuration file and web shared directory here web the document root directory