1. Configure Apache.
$sudo vi /etc/apache2/httpd.conf
1.1. PHP is NOT included in Sequoia. Apple even includes the following note at line 187 of this file:
#PHP was deprecated in macOS 11 and removed from macOS 12
1.2. Enable Perl
LoadModule perl_module libexec/apache2/mod_perl.so
1.3. Enable personal websites
LoadModule userdir_module libexec/apache2/mod_userdir.so
Include /private/etc/apache2/extra/httpd-userdir.conf
2. An important new ACL change that are required in Sequoia for personal websites.
$sudo vi /etc/apache2/extra/httpd-userdir.conf
Include /private/etc/apache2/users/*.conf
3. Create personal web sites
$mkdir ~/Sites
echo “
4. Configure document root for Apache.
4.1. $sudo vi /etc/apache2/httpd.conf
DocumentRoot “/Users/your_user/Sites”
Directory “/Users/your_user/Sites”
In that same block you will find an AllowOverride setting.Change to
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
4.2. Enable mod_rewrite.
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
4.3. User & Group
By default, apache runs as the user _www and group _www. This will cause permission problems when trying to access files in our home directory.
User your_user
Group staff
4.4. ServerName Configuraton:
Change
#ServerName www.example.com:8080
to
ServerName localhost
5. Create your_user.conf
Check if the /etc/apache2/users/your_user.conf exists.
$sudo vi /etc/apache2/users/your_user.conf
AddLanguage en .en
AddHandler perl-script .pl
PerlHandler ModPerl::Registry
Options Indexes MultiViews FollowSymLinks ExecCGI
AllowOverride All
Require host localhost
6. Give the Apache web server access to the Sites folder
$chmod +a “_www allow execute” ~
This will add an ACL permission to your home directory that will allow the Apache web server access to all subdirectories inside your home directory
7. Check your configuration
$apachectl configtest
If this command returns “Syntax OK” then you are ready to go. It may also print warnings saying “https: apr_sockaddr_info_get() failed for…” and/or “httpd: Could not reliably determine the server’s fully qualified domain name”. You could fix these by setting the ServerName directive in /etc/apache2/httpd.conf and adding a matching entry into /etc/hosts. But for a development server, you don’t need to do anything. You can just ignore those warnings.
If AH00558: Could not reliably determine the server’s fully qualified domain name.
$sudo vi /etc/apache2/httpd.conf
ServerName localhost:80
8. Turn on the Apache httpd service
$sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
9. Bump Apache to reload with the configuration changes you’ve just made.
$sudo apachectl graceful
10. Input in Safari
http://localhost/
It should say:
It works!
11. Try your user home directory
http://localhost/~your_user
It should say:
My site works
12. Test Perl, create a Perl test file.
$vi ~/Sites/info.pl
#!/usr/bin/perl
use CGI;
my $cgi = CGI->new;
print $cgi->header( -type => ‘text/plain’ );
print $ENV{SERVER_SOFTWARE};
Input in Safari
http://localhost/~your_user/info.pl
It should say:
Apache/2.4.62 (Unix) mod_perl/2.0.12 Perl/v5.34.1
Reference:
Setting up a local web server on macOS 15 “Sequoia”