0% found this document useful (0 votes)
46 views

Rackspace Support Network: Install Apache and PHP On Centos 6

This document provides steps to install Apache and PHP on CentOS 6 using the default package manager yum. It describes how to start Apache, set the server name, open the required port, test the installation, configure Apache to start automatically, and install PHP and required modules.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Rackspace Support Network: Install Apache and PHP On Centos 6

This document provides steps to install Apache and PHP on CentOS 6 using the default package manager yum. It describes how to start Apache, set the server name, open the required port, test the installation, configure Apache to start automatically, and install PHP and required modules.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

 Support: 1-800-961-4454

 Feedback

 Log In

 Sign Up

System Status

RackspaceSupport HomeHow-ToCommunityAPI DocumentationDevelopers

Rackspace Support Network

We've improved our Knowledge Center!

Our comprehensive Knowledge Center has been redesigned. We're calling it "How-To." Take a look!

How–To Home

Cloud Servers

 Introduction
 FAQ
 All Articles

Have Feedback?

We love customer feedback. Help us improve our products and service by leaving your comments.

Edit This Article

Install Apache and PHP on CentOS 6


 Last updated on: 2016-06-21
 Authored by: Rackspace Support

This article demonstrates how to install Apache and PHP on CentOS 6. CentOS 6 comes with Apache 2.2.3 and PHP
5.1.6, and you can install them by using the default CentOS Package Manager, yum. The advantages of using yum (as
opposed to installing by using source code) are that you get any security updates (when they are distributed) and
dependencies are automatically handled.

Install Apache

1. Run the following command:


2. sudo yum install httpd mod_ssl
3. Because the server does not start automatically when you install Apache, you must start it manually.
4. sudo /usr/sbin/apachectl start

The following message is displayed:

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain
name, using 127.0.0.1 for ServerName

The IP address (shown in this example as 127.0.0.1) is used as the server name by default. In the following
steps, set the server name for the next time the server is started.

5. Open the main Apache configuration file.


6. sudo nano /etc/httpd/conf/httpd.conf
7. Toward the end of the file, locate the section that starts with ServerName and gives an example.
8. #ServerName www.example.com:80
9. Enter your cloud server host name or a fully qualified domain name. In the following example, the host name
is demo.
10. ServerName demo
11. Reload Apache.
12. sudo /usr/sbin/apachectl restart

Open the port to run Apache

Apache runs on port 80. In some versions of CentOS, a firewall, which is installed by default, blocks access to port
80. Perform the following steps to open the port.

1. Run the following command:


2. sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
3. After adding that instruction, save your firewall rules so that your web server is accessible the next time you
reboot.
4. sudo service iptables save

Test the Apache installation

Navigate to your Cloud Server IP address (for example, http://123.45.67.89).

If the default CentOS Apache “welcome” screen is displayed, the installation was successful. Contact Rackspace
support if you have any problems.

Configure Apache to run automatically

Now that Apache is installed and working, set to start automatically when the server is rebooted.

1. Run the following command:


2. sudo /sbin/chkconfig httpd on
3. Test to confirm that the setting works.
4. sudo /sbin/chkconfig --list httpd
5. httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Install PHP

1. Run the following command:


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

The preceding command does not install all the modules available, just a few common ones.

3. Reload Apache.
4. sudo /usr/sbin/apachectl restart

Continue the conversation in the Rackspace Community.

Start building on our Managed Cloud today.

Sign Up Now

©2016 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-
NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER

Support

 Support Home
 Rackspace How-To
 Rackspace Community
 API Documentation
 Developer Center

About Rackspace

 Our Story
 Case Studies
 Events
 Programs
 Newsroom

 The Rackspace Blog


 Developer Blog
 Contact Information
 Legal
 Careers

Blogs

 The Rackspace Blog


 Developer Blog
 Customer Stories
 New Products

 Privacy Statement
 Website Terms
 Trademarks
 Sitemap
 Feedback

© 2016 Rackspace US, Inc.

You might also like