{"id":1928,"date":"2017-08-12T21:26:15","date_gmt":"2017-08-12T15:56:15","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1928"},"modified":"2026-09-10T08:59:17","modified_gmt":"2026-09-10T03:29:17","slug":"install-apache2-php7-mysql-redhat-7-server","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/install-apache2-php7-mysql-redhat-7-server\/","title":{"rendered":"How to Install Apache, PHP, and MySQL on Red Hat 7?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apache is one of the most widely used open-source web servers for hosting websites and web applications. PHP is a popular server-side scripting language, while MySQL is a commonly used relational database management system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we will explain how to install and configure <strong>Apache, PHP 7, and MySQL<\/strong> on a <strong>Red Hat Enterprise Linux 7 (RHEL 7)<\/strong> server. We will also create a simple PHP information page to verify that PHP is working correctly with Apache.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding with the installation, make sure you have the following:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A server running <strong>Red Hat Enterprise Linux 7<\/strong>.<\/li>\n\n\n\n<li><strong>Root or sudo access<\/strong> to the server.<\/li>\n\n\n\n<li>An active internet connection to download the required packages.<\/li>\n\n\n\n<li>A valid IP address or domain name to access the web server.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Install Apache<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Log in to the server and install the Apache HTTP server using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install httpd<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will install Apache HTTP Server 2.4 on the Red Hat 7 server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enable Apache to start automatically during system boot:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable httpd.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Start the Apache service:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start httpd.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can verify the Apache service status using:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl status httpd.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The default Apache document root is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/var\/www\/html<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Enable the EPEL Repository<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Install the EPEL repository using:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rpm -Uvh https:\/\/dl.fedoraproject.org\/pub\/epel\/epel-release-latest-7.noarch.rpm<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then install the Webtatic repository:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rpm -Uvh https:\/\/mirror.webtatic.com\/yum\/el7\/webtatic-release.rpm<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Install PHP<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Install PHP 7 and the required PHP extensions:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install php70w php70w-mysql php70w-gd php70w-pear php70w-xml php70w-soap php70w-xmlrpc php70w-mbstring php70w-json php70w-mcrypt<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After installing PHP, restart Apache:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart httpd.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can verify the installed PHP version using:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php -v<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Create a PHP Information Page<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a PHP test file inside the Apache document root:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/var\/www\/html\/info.php<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following content:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;?php<br>phpinfo();<br>?&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file and access it from a web browser using the server&#8217;s IP address or domain name:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http:\/\/IPaddress\/info.php<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If PHP is installed and configured correctly, the PHP information page will be displayed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Install MySQL<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Install MySQL using:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install mysql mysql-server<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Enable MySQL to start automatically after a system reboot:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable mysql.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Start the MySQL service:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start mysql.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the MySQL service status:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl status mysql.service<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also verify the MySQL installation using:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql --version<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we covered the basic installation of <strong>Apache, PHP, and MySQL on a Red Hat 7 server<\/strong>. We installed Apache and PHP, configured the required PHP extensions, installed MySQL, and created a PHP information page to verify the PHP installation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This setup provides the basic <strong>LAMP stack environment<\/strong> required for hosting many PHP-based websites and applications.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> RHEL 7 and several repositories\/packages referenced in this procedure are now outdated. For a new production server, it is recommended to use a currently supported RHEL version and supported PHP\/MySQL packages.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\">1. What is Apache?<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Apache is an open-source web server used to host and serve websites and web applications over HTTP and HTTPS.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">2. What is the default Apache document root on Red Hat 7?<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">The default Apache document root is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/var\/www\/html<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">3. How can I check whether Apache is running?<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Use:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl status httpd<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">4. How can I start Apache?<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Use:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start httpd<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">5. How can I enable Apache at system boot?<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Use:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable httpd<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">6. How can I check the PHP version?<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Use:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php -v<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Related Articles:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-change-mysql-user-authentication-plugin-for-password\/\">How to Change MySQL User Authentication Plugin for Password? &#8211; Pheonix Solutions<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-20-04\/\">How To Move a MySQL Data Directory to a New Location on Ubuntu 20.04? &#8211; Pheonix Solutions<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Talk to our experts<strong>:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for the right technology solution for your business?. Our experts can help with&nbsp;<strong>web hosting, domain registration, DevOps and cloud, software development, web applications, mobile applications, and enterprise solutions<\/strong>. Get in touch with our team&nbsp;<a href=\"https:\/\/pheonixsolutions.com\/contact\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Apache is one of the most widely used open-source web servers for hosting websites and web applications. PHP is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[278,273],"class_list":["post-1928","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-apache","tag-php","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-v6","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1928"}],"version-history":[{"count":3,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1928\/revisions"}],"predecessor-version":[{"id":11601,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1928\/revisions\/11601"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}