Install Apache2 + PHP in Ubuntu

Source: Internet
Author: User
Install Apache2 + PHP in Ubuntu-Linux Enterprise Application-Linux server application information. For more information, see. Few people have shared articles about Ubuntu. Today, we have just installed Apache2 + PHP, so let's talk about the solution together with the installation method!

First, install Apache2 and php4. Because it is in Ubuntu, we use APT for installation, which is more convenient.
Sudo apt-get install apache2 libapache2-mod-php4 php4

If you want to install PHP5, use
Sudo apt-get install Apache 2 libapache2-mod-php5 php5

At this time, you can first execute Apache2 to see if it can be executed.
Sudo apache2ctl start

(Normally, only one message indicating that ServerName is specified to 127.0.1.1 will appear, and so on)

Check whether Apache2 is normal.
Ps-aux

If you execute OK, open the browser http: // localhost and you will be able to see the preset screen. However, you will find that opening the php file will become a download file. At this time, we will open the configuration file.

Sudo gedit/etc/apache2/apache2.conf

First, add
LoadModule php4_module/usr/lib/apache2/modules/libphp4.so

* Note:
Include/etc/apache2/mod-enabled/*. load
Include/etc/apache2/mod-enabled/*. conf

The above two rows are not sure!

Add
ServerName localhost

You can also set your own Domain Name, which can be modified on your own, so that no error message will appear during execution!

Create a new file php4.conf in/etc/apache2/mod-enabled and enter

AddType application/x-httpd-php. php. phtml. php3
AddType application/x-httpd-php-source. phps

(This is a little different from other systems. I encountered a problem here and found the problem only after crawling through Google)

Store and return to the text terminal and re-Execute Apache2.
Sudo apache2ctl restart

Then, test whether the. php file can be opened. If you run OK, the installation is successful!

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.