Use Ubuntu to build a Web server (PHP)

Source: Internet
Author: User
Apache is a powerful Web server. Nowadays, countless Apache servers running on Linux on the Internet are providing powerful support for the increasingly prosperous Web world. This article will show you how to quickly build an ApacheWeb server in the UbuntuLinux system. Although Ubuntu is a new Linux branch, the Ubuntu Organization provides a wide range of support software for Apache, which can be obtained from the CD of the release.

Apache is a powerful Web server. Nowadays, countless Apache servers running on Linux on the Internet are providing powerful support for the increasingly prosperous Web world. This article will show you how to quickly build an Apache Web server in Ubuntu Linux.

Although Ubuntu is a new Linux branch, the Ubuntu Organization provides a wide range of support software for Apache, which can be obtained from the CD of the release version, it can also be easily downloaded from the official site. Therefore, Ubuntu is very suitable for serving as a Web server platform.

1. install Apache

Next, we will first introduce how to install Apache. The installation command is as follows:

$ Sudo apt-get install apache2

Run Apache and the command is as follows:

$ Sudo/etc/init. d/apache2 restart

During installation, Apache creates a directory:/var/www, which is the root directory for storing documents on the server. You only need to enter http: // localhost/or the IP address of the machine in the address bar of the browser to access all documents placed in this directory.

Ii. install PHP

PHP is a popular server-side scripting language. It is generally used in combination with MySQL or Postgres to manage Web content, blogs, and forums. The following describes the installation method. In fact, the installation is very simple. The command is as follows:

$ Sudo apt-get install libapache2-mod-php5

Restart Apache to load the modules installed above:

$ Sudo/etc/init. d/apache2 restart

To verify that the PHP module is correctly loaded, we can create a PHP file and try to access the file through the Web server. In addition, we know that PHP has a built-in phpinfo function that provides detailed information about its environment. Therefore, we can also use the following command to check the working status of PHP:

Sudo sh-c "echo''>/var/www/info. php"

Then, enter http: // localhost/info. php in the address bar of the browser, and press Enter. Then, you will be able to see a face and provide the PHP installation details. Note that if the browser prompts you to download the file instead of displaying the page during this process, Apache does not properly load the PHP module. To solve the problem, add the following command in the/etc/apache2/apache2.conf or/etc/apache2/mod-enabled/php5.conf file:

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

After adding the preceding command line, to ensure that Apache re-reads the configuration file and closes it, we can use the following command to close it and then start it:

$ Sudo/etc/init. d/apache2 stop

$ Sudo/etc/init. d/apache2 start

Related Article

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.