Install apache+php under Ubuntu

Source: Internet
Author: User

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

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.