System Status
Buy Now
  • Email & Apps
  • Office 365
Login
  • MyRackspace Portal
  • Cloud Control Panel
  • Rackspace Webmail Login
  • Cloud Office Control Panel
  • Support Home
  • How-To
  • Developer Documentation
  •  Blogs 
    • Expert Insights Tech Blog
    • Rackspace Blog
    • Solve: Thought Leadership

Support Network

End-to-End Multicloud Solutions.   Solving Together.™   Learn more at Rackspace.com

How–To Home

Cloud Servers

  • Introduction
  • FAQ
  • All Articles

Install Apache and PHP on CentOS 7

Last updated on:  2021-01-15

Authored by:  Rackspace Support


This article demonstrates how to install Apache® and PHP® on CentOS® 7. The default CentOS 7 image doesn’t have access to repositories that support PHP version 5.6 and higher, so you should enable a repository that does. Install this repository by using the default CentOS package manager, yum. The advantage of using yum to perform the installation is that yum automatically installs future security updates and handles dependencies.

NOTE: This guide enables the Inline with Upstream Stable (IUS) repository, which provides newer versions of some software found in the official CentOS and Red Hat® repositories. For more information about the IUS repository, see the [Install EPEL and IUS repositories on CentOS and Red Hat] (/support/how-to/install-epel-and-additional-repositories-on-centos-and-red-hat/) article.

Install Apache

Use the following steps to install Apache:

  1. Run the following command:

     yum install httpd
    
  2. Use the systemd systemctl tool to start the Apache service:

     systemctl start httpd
    
  3. Enable the service to start automatically on boot:

     systemctl enable httpd.service
    
  4. Open up port 80 for web traffic:

     firewall-cmd --add-service=http --permanent
    
  5. Reload the firewall:

     firewall-cmd --reload
    

Confirm successful installation by entering your server’s IP address in a browser to view the default Apache test page.

Install PHP 7.3

Use yum to install a repository that supports PHP 7.3:

  1. Run the following command:

     sudo yum install https://repo.ius.io/ius-release-el7.rpm
    
  2. Install PHP and some popular PHP modules:

     yum install mod_php73 php73-bcmath php73-cli php73-gd php73-ldap php73-mbstring php73-mysqlnd php73-soap
    
  3. Confirm your server is using PHP 7.3 by running the following command:

     php -v
    

You should see the following output:

    PHP 7.3.25 (cli) (built: Dec 1 2020 21:50:13) ( NTS )

Share this information:

©2020 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

About Rackspace
  • About
  • Customer Stories
  • Events
  • Programs
Blogs
  • The Rackspace Blog
  • Expert Insights Tech Blog
  • Solve: Thought Leadership
  • News
  • Contact Information
  • Legal
  • Careers
Site Information
  • Style Guide for Technical Content
  • Trademarks
  • Privacy Statement
  • Website Terms
Support Network
  • Support Network Home
  • Rackspace How-To
  • API Documentation
  • Developer Center
  • ©2020 Rackspace US, Inc.