Installing Apache and PHP on CentOS 6

Source: Internet
Author: User
Tags fully qualified domain name

This article shows you how to install Apache and PHP on CentOS 6. CentOS 6 comes with Apache 2.2.3 and PHP 5.1.6, which you can install using the default CentOS Package Manager yum . yum The advantage of using (instead of using source code for installation) is that you can obtain any security updates (when distributed), and dependencies are automatically processed.

Installing Apache
  1. Run the following command:
    sudo yum install httpd mod_ssl

  2. Because the server does not start automatically when you install Apache, you must start it manually.
    Sudo/usr/sbin/apachectl start

    The following message is displayed:

     not reliably determine the server'sfully qualified domain name, using 127.0.0.1 for ServerName

  3. Open the master configuration file for Apache.
    sudo nano/etc/httpd/conf/httpd.conf

  4. to the end of the file, find the beginning part ServerName and give an example.

    # ServerName www.example.com:80

  5. Enter your cloud server host name or fully qualified domain name. in the following example, the host name is demo .
    ServerName Demo

  6. Reload Apache.

    Sudo/usr/sbin/apachectl restart

Open Port Run Apache

Apache runs on port 80. In some versions of CentOS, firewalls that are installed by default block access to port 80. Perform the following steps to open the port.

    1. Run the following command:
      sudo iptables-i input-p tcp--dport 80-j ACCEPT

After you add the directive, save the firewall rules so that you can access the Web server the next time you restart.

sudo service iptables Save

Test Apache Installation

Browse to your cloud Server IP address (for example http://123.45.67.89 ).

if the default CentOS Apache Welcome screen is displayed, the installation succeeds. If you have any questions, please contact Rackspace.

Configure Apache to run automatically

Apache is now installed and working, and is set to start automatically when the server is restarted.

    1. Run the following command:

      Sudo/sbin/chkconfig httpd on

Test to confirm that the settings are correct.

Sudo/sbin/chkconfig--list httpd httpd           0:off        1:off 2:on 3:on 4:on    5:on    6:o Ff
Install PHP
    1. Run the following command:

      sudo yum install php php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml

The above command will not install all available modules, just some of the most commonly used modules.

2. Reload Apache.

Sudo/usr/sbin/apachectl restart

Installing Apache and PHP on CentOS 6

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.