Running Perl CGI on the macOS / Mac OS X Apache Web Server, In addition to the above steps to enable CGI in Apache server, the problem was in my python script as it was sending bad HTML info back to the OS: MacOS Catalina. Apache Server: 2.4.41.
How to turn off and turn back on the built in apache on OSx
A handy ssh book for beginners and forgetful veteran developers and Unix/Linux/macOS users. Open a terminal and than type the following command to restart the apache 2 web server: $ sudo /usr/sbin/apachectl restart. $ sudo apachectl -k restart. Sample outputs: Restart Apache 2 Mac OS X. 設定を変更した際は再起動が必要になります。 $ sudo apachectl restart 個人的にはApacheの挙動を知っておくと、色々と勉強になると思っているので 今後Webサーバとかも勉強したいなーという方は、Apacheの設定をいじり倒すと楽しいかもしれません。. Httpd.conf is the Apache web server’s main configuration file. Mac OSX ships with Apache installed. See Apache’s configuration docs for how to configure Apache. Httpd.conf Location on Mac. On Mac httpd.conf location is in the directory /etc/apache2. You can access this folder through the Mac Finder or through the Mac Terminal.
There are a handful of reasons why you would want to turn off the built in apache on OSx, you might have installed your own version, maybe you don’t use apache and it is interfering with something else, whatever the reason there is one command you need to run to turn it off.
You should run that from Terminal.app
I wanted to take a second to explain what is going on because too often people (myself included) will post a code snippet without explaining what it is, the worrying this is so many people run them without checking what is happening.
sudo
tells your computer to run the following command as the root (administrator) account.
launchctl
is an OSx program that interfaces with launchd
, which is a daemon manager. Daemons are small programs that run as background processes (like what would setup Apache).
unload
tells launchctl to unload a specified configuration file.
-w
tells launchctl to override a disabled key, basically this will force the file to be marked as disabled.
/System/Library/LaunchDaemons/org.apache.httpd.plist
is the file that we are unloading.
If you want to load Apache back in, we simply need to run the same command with load
instead of unload
:
Hopefully that helps! If you have any questions, please look through the comments as lots of smart people have been talking in there.