{"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":"aapanel-php-7-4-apache-wordpress-ubuntu-24-04-guide","status":"publish","type":"post","link":"https:\/\/dps.media\/en\/aapanel-php-7-4-apache-wordpress-ubuntu-24-04-guide\/","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 data-no-translation=\"\">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 data-no-translation=\"\"><code data-no-translation=\"\"># T\u1ea3i g\u00f3i libssl1.1\nwget http:\/\/security.ubuntu.com\/ubuntu\/pool\/main\/o\/openssl\/libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb\n\n# C\u00e0i \u0111\u1eb7t g\u00f3i v\u00e0o h\u1ec7 th\u1ed1ng\nsudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.24_amd64.deb<\/code><\/pre>\n<p>Installing <code data-no-translation=\"\">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 data-no-translation=\"\"><code data-no-translation=\"\">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 data-no-translation=\"\">.htaccess<\/code> missing parameter <code data-no-translation=\"\">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 data-no-translation=\"\">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 data-no-translation=\"\"><code data-no-translation=\"\"># BEGIN WordPress\n&lt;IfModule mod_rewrite.c&gt;\nRewriteEngine On\nRewriteBase \/ten-thu-muc-cua-ban\/\nRewriteRule ^index.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/ten-thu-muc-cua-ban\/index.php [L]\n&lt;\/IfModule&gt;\n# END WordPress<\/code><\/pre>\n<p>Important note: You must replace <code data-no-translation=\"\">\/ten-thu-muc-cua-ban\/<\/code> with the actual folder name where WordPress is installed (e.g., <code data-no-translation=\"\">\/bikipthandong\/<\/code>). Also, ensure the folder ownership (Owner) is set to <code data-no-translation=\"\">www<\/code> and access permissions are <code data-no-translation=\"\">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 data-no-translation=\"\">wp-config.php<\/code> in your installation directory and insert the following header detection code <code data-no-translation=\"\">X-Forwarded-Proto<\/code> right above the line `\/* That\u2019s all, stop editing! *\/`:<\/p>\n<pre data-no-translation=\"\"><code data-no-translation=\"\">\/* Nh\u1eadn di\u1ec7n HTTPS t\u1eeb 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\/* \u00c9p bu\u1ed9c URL ch\u00ednh x\u00e1c \u0111\u1ec3 tr\u00e1nh v\u00f2ng l\u1eb7p *\/\ndefine('WP_HOME', 'https:\/\/yourdomain.com\/subfolder');\ndefine('WP_SITEURL', 'https:\/\/yourdomain.com\/subfolder');<\/code><\/pre>\n<p>Usage <code data-no-translation=\"\">define('WP_HOME', ...)<\/code> v\u00e0 <code data-no-translation=\"\">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>","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}]}}