Install MacPorts based on your mac version.
pls see https://www.macports.org/install.php
if you have already MacPorts, pls update/upgrade it:
|
1 |
sudo port -v selfupdate |
Install PHP7.4
read: https://ports.macports.org/port/php74/
run: sudo port install php74
install some php7.4 extension: sudo port install php74-apache2handler php74-cgi php74-gd php74-curl php74-intl php74-iconv php74-gettext php74-mbstring php74-imap php74-mcrypt php74-xmlrpc php74-mysql php74-openssl php74-sockets php74-zip php74-tidy php74-opcache php74-xsl php74-sqlite php74-xdebug
Select php74 as the active PHP version:
sudo port select php php74
check:
php -v
PHP 7.4.33 (cli) (built: Oct 13 2024 09:21:46) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
with Xdebug v3.1.6, Copyright (c) 2002-2022, by Derick Rethans
Install Apache2
check apache2: (the default apache2 from mac)
[codesyntax lang=”bash”]
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
httpd -V [Tue May 20 20:27:24.618540 2025] [so:warn] [pid 902] AH06665: No code signing authority for module at /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so specified in LoadModule directive. Proceeding with loading process, but this will be an error condition in a future version of macOS. httpd: Syntax error on line 188 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so, 10): image not found Server version: Apache/2.4.56 (Unix) Server built: Apr 12 2023 20:59:26 Server's Module Magic Number: 20120211:126 Server loaded: APR 1.5.2, APR-UTIL 1.5.4, PCRE 8.44 2020-02-12 Compiled using: APR 1.5.2, APR-UTIL 1.5.4, PCRE 8.44 2020-02-12 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_FLOCK_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/usr" -D SUEXEC_BIN="/usr/bin/suexec" -D DEFAULT_PIDLOG="/private/var/run/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types" -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf" |
[/codesyntax]
read: https://trac.macports.org/wiki/howto/Apache2
|
1 |
sudo port install apache2 |
verify the config file:
[codesyntax lang=”bash”]
|
1 2 3 |
/opt/local/sbin/apachectl -t AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Satrias-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message Syntax OK |
[/codesyntax]
Activate apache2 :
sudo port load apache2
to remove the warning:
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using Satrias-MacBook-Pro.local. Set the ‘ServerName’ directive globally to suppress this message
edit /opt/local/etc/apache2/httpd.conf –> should use admin to edit it
Open geany as admin via command line: sudo “/Applications/Geany.app/Contents/MacOS/geany”
then add this line:
ServerName localhost:80
then unload and load again apache2:
sudo port unload apache2
sudo port load apache2
then
[codesyntax lang=”bash”]
|
1 2 |
/opt/local/sbin/apachectl -t Syntax OK |
[/codesyntax]
Test it on the browser: http://localhost/ –> it should work
Link PHP7.4 with apache2
read: https://trac.macports.org/wiki/howto/MAMP
Go to this dir:
cd /opt/local/lib/apache2/modules
then run:
[codesyntax lang=”bash”]
|
1 2 3 |
sudo /opt/local/bin/apxs -a -e -n php7 mod_php74.so Password: [activating module `php7' in /opt/local/etc/apache2/httpd.conf] |
[/codesyntax]
then modify /opt/local/etc/apache2/httpd.conf, so it’ll be:
DirectoryIndex index.php index.html