{"id":36407,"date":"2026-02-03T12:21:47","date_gmt":"2026-02-03T05:21:47","guid":{"rendered":"https:\/\/dps.media\/huong-dan-aapanel-php-7-4-apache-wordpress-ubuntu-24-04\/"},"modified":"2026-02-03T12:21:47","modified_gmt":"2026-02-03T05:21:47","slug":"huong-dan-aapanel-php-7-4-apache-wordpress-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/dps.media\/en\/huong-dan-aapanel-php-7-4-apache-wordpress-ubuntu-24-04\/","title":{"rendered":"Installing PHP 7.4 on aaPanel with Apache: Comprehensive Guide for WordPress Subdirectory"},"content":{"rendered":"<h2>Detailed guide to installing and configuring PHP 7.4 on aaPanel with Apache: Optimal solution for Ubuntu 24.04<\/h2>\n<p>Operating legacy websites running on PHP 7.4 is becoming increasingly challenging as modern operating systems like Ubuntu 24.04 emerge. Ubuntu 24.04 (Noble Numbat) brings many security and performance improvements, but it also removes old libraries required by PHP 7.4 to function. This article delves into the most complex technical issues when using aaPanel, from installing dependencies to optimizing Apache configuration and handling redirect loop errors.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/dps.media\/wp-content\/uploads\/2026\/02\/technical_coding_htaccess_wpconfig_1770095972822.jpg\" alt=\"htaccess and wp-config configuration tips\" title=\"\"><\/p>\n<h3>1. Why is PHP 7.4 difficult to install on Ubuntu 24.04?<\/h3>\n<p>The main reason lies in the changes to the OpenSSL library. Ubuntu 24.04 uses OpenSSL 3.0, while PHP 7.4 is designed to be compatible with OpenSSL 1.1. Additionally, the default software repositories of the new Ubuntu no longer support PHP versions that have reached end-of-life (EOL) like 7.4. To overcome this barrier, we cannot use the \u201cFast\u201d installation method (installing from prebuilt binaries) in aaPanel because these packages are often incompatible with Ubuntu 24.04's new library structure.<\/p>\n<p>aaPanel provides two ways to install software: Fast (RPM\/DEB) and Compiled (built from source). For PHP 7.4 on Ubuntu 24.04, the only option is Compiled. During compilation, the system automatically searches for available header files and libraries on the server to create the most compatible executable. This eliminates errors related to \u201cshared library not found\u201d commonly encountered with prebuilt packages.<\/p>\n<h3>2. Step 1: Install Legacy Dependencies<\/h3>\n<p>Before starting PHP installation in the aaPanel interface, you must prepare the system environment. The most important library is <code>libssl1.1<\/code>. Follow these commands to manually download and install it from the Ubuntu Focal security repository (an older version but still safely compatible):<\/p>\n<pre><code># Download libssl1.1 package\nwget http:\/\/security.ubuntu.com\/ubuntu\/pool\/main\/o\/openssl\/libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb\n\n# Install the package into the system\nsudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb<\/code><\/pre>\n<p>Installing <code>libssl1.1<\/code> is completely safe and does not conflict with the existing OpenSSL 3.0. These two libraries exist independently as separate `.so` files (libssl.so.1.1 and libssl.so.3). Modern system applications will continue using version 3.0, while PHP 7.4 will find the required 1.1 version.<\/p>\n<p>Additionally, installing compilation tools is mandatory for aaPanel to build PHP from source:<\/p>\n<pre><code>sudo apt update\nsudo apt install -y build-essential libxml2-dev libssl-dev libsqlite3-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libonig-dev libzip-dev<\/code><\/pre>\n<h3>3. Step 2: Install PHP 7.4 from aaPanel App Store<\/h3>\n<p>Once the necessary libraries are available, access the aaPanel App Store. Search for PHP 7.4 and click Install. A popup will appear asking you to choose the installation method. <strong>Select \u201cCompiled\u201d instead of \u201cFast\u201d.<\/strong><\/p>\n<p>The compilation process will take about 15-30 minutes depending on your server's CPU power. This method ensures PHP automatically links to the libraries available on your Ubuntu 24.04 accurately. Don't forget to open the task manager (the spinning arrow icon at the top right) to monitor progress.<\/p>\n<h3>4. Advanced .htaccess configuration for WordPress subfolders<\/h3>\n<p>Many users encounter 500 Internal Server Error when running WordPress in subfolders on Apache. This is often due to the file <code>.htaccess<\/code> missing parameter <code>RewriteBase<\/code>. Apache needs to know the base path of the subfolder to handle URL requests. Without this configuration, Apache will attempt to find files <code>index.php<\/code> in the root directory of the domain, causing not found errors or internal redirect loops.<\/p>\n<p>Here is an optimal configuration example for a subfolder:<\/p>\n<pre><code># BEGIN WordPress\n\nRewriteEngine On\nRewriteBase \/your-subfolder\/\nRewriteRule ^index.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/your-subfolder\/index.php [L]\n\n# END WordPress<\/code><\/pre>\n<p>Important note: You must replace <code>\/your-subfolder\/<\/code> with the actual folder name where WordPress is installed (e.g., <code>\/mywordpressfolder\/<\/code>). Also, ensure the folder ownership (Owner) is set to <code>www<\/code> and access permissions are <code>755<\/code> so Apache can read the files.<\/p>\n<h3>5. Fixing ERR_TOO_MANY_REDIRECTS<\/h3>\n<p>This error most commonly occurs in aaPanel's \u201cMulti Webserver\u201d setup (Nginx frontend acting as Reverse Proxy and Apache backend). Nginx receives HTTPS connections from the user's browser and forwards requests to Apache over HTTP (port 80 or internal port). WordPress on the backend does not recognize the original HTTPS connection, causing it to repeatedly issue HTTPS redirects, creating an endless loop and triggering `Too Many Redirects` in the browser.<\/p>\n<p>To fix this thoroughly, you need to enforce protocol recognition in the WordPress configuration file. Open the file <code>wp-config.php<\/code> in your installation directory and insert the following header detection code <code>X-Forwarded-Proto<\/code> right above the line `\/* That\u2019s all, stop editing! *\/`:<\/p>\n<pre><code>\/* Detect HTTPS from Reverse Proxy (Nginx) *\/\nif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &amp;&amp; $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {\n    $_SERVER['HTTPS'] = 'on';\n}\n\n\/* Force correct URL to prevent loops *\/\ndefine('WP_HOME', 'https:\/\/yourdomain.com\/subfolder');\ndefine('WP_SITEURL', 'https:\/\/yourdomain.com\/subfolder');<\/code><\/pre>\n<p>Usage <code>define('WP_HOME', ...)<\/code> and <code>define('WP_SITEURL', ...)<\/code> in the config file takes priority over database settings, quickly resolving URL misconfiguration errors when you cannot access the Admin panel.<\/p>\n<h3>6. Conclusion and recommendations<\/h3>\n<p>Although PHP 7.4 has officially reached the end of its security lifecycle, the need to maintain legacy WordPress applications remains significant. By using aaPanel on Ubuntu 24.04 combined with Apache compilation techniques and Proxy Header configuration, you can create a stable and professional environment. However, always plan to upgrade your applications to newer PHP versions (such as 8.1 or 8.3) in the near future for maximum security.<\/p>\n<p>Wishing you success in mastering your server!<\/p>\n<style>\r\n.lwrp.link-whisper-related-posts{\r\n            \r\n            margin-top: 40px;\nmargin-bottom: 30px;\r\n        }\r\n        .lwrp .lwrp-title{\r\n            \r\n            \r\n        }.lwrp .lwrp-description{\r\n            \r\n            \r\n\r\n        }\r\n        .lwrp .lwrp-list-container{\r\n        }\r\n        .lwrp .lwrp-list-multi-container{\r\n            display: flex;\r\n        }\r\n        .lwrp .lwrp-list-double{\r\n            width: 48%;\r\n        }\r\n        .lwrp .lwrp-list-triple{\r\n            width: 32%;\r\n        }\r\n        .lwrp .lwrp-list-row-container{\r\n            display: flex;\r\n            justify-content: space-between;\r\n        }\r\n        .lwrp .lwrp-list-row-container .lwrp-list-item{\r\n            width: calc(33% - 20px);\r\n        }\r\n        .lwrp .lwrp-list-item:not(.lwrp-no-posts-message-item){\r\n            \r\n            max-width: 150px;\r\n        }\r\n        .lwrp .lwrp-list-item img{\r\n            max-width: 100%;\r\n            height: auto;\r\n            object-fit: cover;\r\n            aspect-ratio: 1 \/ 1;\r\n        }\r\n        .lwrp .lwrp-list-item.lwrp-empty-list-item{\r\n            background: initial !important;\r\n        }\r\n        .lwrp .lwrp-list-item .lwrp-list-link .lwrp-list-link-title-text,\r\n        .lwrp .lwrp-list-item .lwrp-list-no-posts-message{\r\n            \r\n            \r\n            \r\n            \r\n        }@media screen and (max-width: 480px) {\r\n            .lwrp.link-whisper-related-posts{\r\n                \r\n                \r\n            }\r\n            .lwrp .lwrp-title{\r\n                \r\n                \r\n            }.lwrp .lwrp-description{\r\n                \r\n                \r\n            }\r\n            .lwrp .lwrp-list-multi-container{\r\n                flex-direction: column;\r\n            }\r\n            .lwrp .lwrp-list-multi-container ul.lwrp-list{\r\n                margin-top: 0px;\r\n                margin-bottom: 0px;\r\n                padding-top: 0px;\r\n                padding-bottom: 0px;\r\n            }\r\n            .lwrp .lwrp-list-double,\r\n            .lwrp .lwrp-list-triple{\r\n                width: 100%;\r\n            }\r\n            .lwrp .lwrp-list-row-container{\r\n                justify-content: initial;\r\n                flex-direction: column;\r\n            }\r\n            .lwrp .lwrp-list-row-container .lwrp-list-item{\r\n                width: 100%;\r\n            }\r\n            .lwrp .lwrp-list-item:not(.lwrp-no-posts-message-item){\r\n                \r\n                max-width: initial;\r\n            }\r\n            .lwrp .lwrp-list-item .lwrp-list-link .lwrp-list-link-title-text,\r\n            .lwrp .lwrp-list-item .lwrp-list-no-posts-message{\r\n                \r\n                \r\n                \r\n                \r\n            };\r\n        }<\/style>\r\n<div id=\"link-whisper-related-posts-widget\" class=\"link-whisper-related-posts lwrp\">\r\n            <div class=\"lwrp-title\">Related Posts<\/div>    \r\n        <div class=\"lwrp-list-container\">\r\n                                <div class=\"lwrp-list lwrp-list-row-container lwrp-list-double-row\">\r\n                <div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/en\/facebook-advertising-guarantees-sales\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">The Truth About Facebook Ads Commitment to Business Results<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/en\/fashion-industry-report-2026-social-commerce-battle-rise-of-local-brand\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">2026 Fashion Industry Report: Social Commerce War &amp; Rise of Local Brands<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/en\/shopee-ads-guide-real-combat-from-zero\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">Guide to Running Shopee Ads from Scratch: Valuable Lessons from Real Operations<\/span><\/a><\/div>                <\/div>\r\n                            <div class=\"lwrp-list lwrp-list-row-container lwrp-list-double-row\">\r\n                <div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/en\/what-is-a-needle-tree-viral-song-causing-a-social-media-sensation\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">What is the Lucky Bamboo? The viral song causing a stir on social media<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/en\/the-development-journey-of-dps-media-from-2017-to-now\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">The development journey of DPS.MEDIA from 2017 to present<\/span><\/a><\/div><div class=\"lwrp-list-item\"><a href=\"https:\/\/dps.media\/en\/booking-kol-modern-and-effective-marketing-solutions\/\" class=\"lwrp-list-link\"><span class=\"lwrp-list-link-title-text\">KOL Booking \u2013 Modern And Effective Marketing Solution<\/span><\/a><\/div>                <\/div>\r\n                <\/div>\r\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Detailed guide to installing and configuring PHP 7.4 on aaPanel with Apache: Optimal solution for Ubuntu 24.04 Operating old website systems on PHP 7.4 foundation is increasingly challenging with modern OS like Ubuntu 24.04. Ubuntu [\u2026]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1906,1905,1204],"tags":[],"class_list":["post-36407","post","type-post","status-publish","format-standard","hentry","category-aapanel-setup","category-ky-thuat-spinning","category-wordpress-marketing"],"acf":[],"rankmath_keywords":{"primary":"aapanel php 7.4, apache wordpress, ubuntu 24.04 php 7.4, htaccess wordpress subfolder","secondary":[""]},"yoast_keywords":{"primary":"","secondary":[]},"yoast_focuskw":"","rankmath_focuskw":"aapanel php 7.4, apache wordpress, ubuntu 24.04 php 7.4, htaccess wordpress subfolder","seo_keywords":{"primary":"aapanel php 7.4, apache wordpress, ubuntu 24.04 php 7.4, htaccess wordpress subfolder","secondary":[""]},"_links":{"self":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/posts\/36407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/comments?post=36407"}],"version-history":[{"count":0,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/posts\/36407\/revisions"}],"wp:attachment":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/media?parent=36407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/categories?post=36407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/tags?post=36407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}