Local – Web / MySQL / Mail Server | Mac Catalina *

Web ServerMySQLMail Server

https://discussions.apple.com/docs/DOC-250001766

Setting up a local web server on macOS 10.15 “Catalina”

Here is my definitive guide to getting a local web server running on macOS 10.15 “Catalina”. This is meant to be a development platform so that you can build and test your sites locally, then deploy to an internet server. This User Tip only contains instructions for configuring the Apache server, PHP module, and Perl module. I have another User Tip for installing and configuring MySQL and email servers.

 

Note: This user tip is specific to macOS 10.15 “Catalina”. Pay attention to your OS version. There have been significant changes since earlier versions of macOS. Another note: These instructions apply to the client versions of OS X, not Server. Server does a few specific tricks really well and is a good choice for those. For things like database, web, and mail services, I have found it easier to just setup the client OS version manually.

 

Requirements:

  1. Basic understanding of Terminal.app and how to run command-line programs.
  2. Basic understanding of web servers.
  3. Basic usage of vi. You can substitute nano if you want.

 

Optional: Xcode is required for adding PHP modules.

 

Lines in bold are what you will have to type in. Lines in bold courier should be typed at the Terminal.Replace with your short user name.

 

Here goes… Enjoy!

 

To get started, edit the Apache configuration file as root:

sudo vi /etc/apache2/httpd.conf

 

Enable PHP by uncommenting line 186, changing:

#LoadModule php7_module libexec/apache2/libphp7.so

to

LoadModule php7_module libexec/apache2/libphp7.so

(If you aren't familiar with vi, go to line 186 by typing "186G" (without the quotes). Then just press 'x' over the '#' character to delete it. Then type ':w!' to save, or just 'ZZ' to save and quit. Don't do that yet though. More changes are still needed.)

 

If you want to run Perl scripts, you will have to do something similar:

 

Enable Perl by uncommenting line 187, changing:

#LoadModule perl_module libexec/apache2/mod_perl.so

to

LoadModule perl_module libexec/apache2/mod_perl.so

 

Enable personal websites by uncommenting the following at line 183:

#LoadModule userdir_module libexec/apache2/mod_userdir.so

to

LoadModule userdir_module libexec/apache2/mod_userdir.so

 

and do the same at line 520:

#Include /private/etc/apache2/extra/httpd-userdir.conf

to

Include /private/etc/apache2/extra/httpd-userdir.conf

Now save and quit.

 

Open the file you just enabled above with:

sudo vi /etc/apache2/extra/httpd-userdir.conf

and uncomment the following at line 16:

#Include /private/etc/apache2/users/*.conf

to

Include /private/etc/apache2/users/*.conf

Save and exit.

 

Lion and later versions no longer create personal web sites by default. If you already had a Sites folder in Snow Leopard, it should still be there. To create one manually, enter the following:

mkdir ~/Sites

echo "

My site works

" > ~/Sites/index.html.en

 

While you are in /etc/apache2, double-check to make sure you have a user config file. It should exist at the path: /etc/apache2/users/.conf.

 

That file may not exist and if you upgrade from an older version, you may still not have it. It does appear to be created when you create a new user. If that file doesn't exist, you will need to create it with:

sudo vi /etc/apache2/users/.conf

 

Use the following as the content:

<Directory "/Users//Sites/">

AddLanguage en .en

AddHandler perl-script .pl

PerlHandler ModPerl::Registry

Options Indexes MultiViews FollowSymLinks ExecCGI

AllowOverride None

Require host localhost

 

Now you are ready to turn on Apache itself. But first, do a sanity check. Sometimes copying and pasting from an internet forum can insert invisible, invalid characters into config files. Check your configuration by running the following command in the Terminal:

apachectl configtest

 

If this command returns "Syntax OK" then you are ready to go. It may also print a warning saying "httpd: Could not reliably determine the server's fully qualified domain name". You could fix this 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 that warning. You can safely ignore other warnings too.

 

Turn on the Apache httpd service by running the following command in the Terminal:

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

 

In Safari, navigate to your web site with the following address:

http://localhost/

 

It should say:

 

It works!

 

Now try your user home directory:

[http://localhost/~ short user name>**

 

It should say:

 

My site works

 

Now try PHP. Create a PHP info file with:

echo "" > ~/Sites/info.php

 

And test it by entering the following into Safari's address bar:

[http://localhost/~ short user name>/info.php**

 

You should see your PHP configuration information.

 

To test Perl, try something similar. Create a Perl test file with:

echo "print $ENV{MOD_PERL} . qq{\n};" > ~/Sites/info.pl

 

And test it by entering the following into Safari's address bar:

[http://localhost/~ short user name>/info.pl**

 

You should see the string "mod_perl/2.0.9".

 

If you want to setup MySQL, see my User Tip on Installing MySQL.

 

If you want to add modules to PHP, I suggest the following site. I can't explain it any better.

 

If you want to make further changes to your Apache system or user config files, you will need to restart the Apache server with:

sudo apachectl graceful

 

https://discussions.apple.com/docs/DOC-3082

Installing MySQL on OS X

Rating: 4 out of 5★★★★★166 likes57,962 viewsLast modified Jun 27, 2021 6:55 PM

This User Tip describes how to download, install, and setup MySQL for use on macOS. Please read through the entire User Tip before starting.

 

Requirements:

  • Basic understanding of Terminal.app and how to run command-line programs.

 

Download MySQL from a local mirror. You want the Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive. At the time of writing this User Tip, the current version is 8.0.25. By the time you read this, there may be a newer version to use instead. Open the archive mysql-8.0.25-macos11-x86_64.dmg.

Double-click the mysql-5.5.34-osx10.6-x86_64.pkg package to install.

 

MySQL is now up and running. You can control the server from the newly installed Preference pane in System Preferences > MySQL.

 

If you want to run MySQL from the command line, you will need to setup the following aliases:

alias mysql=/usr/local/mysql/bin/mysql

alias mysqladmin=/usr/local/mysql/bin/mysqladmin

 

You can add these to your .zshrc file or add /usr/local/mysql/bin to your PATH.

 

 

https://discussions.apple.com/docs/DOC-4161

Local mail server for OS X

Rating: 5 out of 5★★★★★11 like15,237 viewsLast modified Nov 24, 2013 4:15 PM

This is meant to be a follow-on to my User Tip Setting up a local web server on OS X. Setting up a mail server is a bit more complex and not always required, so I put this document into its own post. I tried to use mail server in OS X Server, but found this process easier. 🙂

 

Requirements:

  1. Solid understanding of Terminal.app and how to run command-line programs.
  2. Basic understanding of mail servers.
  3. Basic usage of vi. You can substitute nano if you want.
  4. Xcode and basic understanding of how to build software form the command line.

 

Lines in bold are what you will have to type in at the Terminal.

Replace with the name of your machine. Ideally, it should be a one-word name with no spaces or punctuation. It just makes life easier.

Replace with your short user name.

Replace with your password.

 

Here goes… Enjoy!

 

Download the UW IMAP software fromftp://ftp.cac.washington.edu/imap

If using the Finder

  1. from the Go menu choose Connect to Server…
  2. enter ftp://ftp.cac.washington.edu/imap under Server Address:
  3. Login as guest
  4. Drag the file imap-2007f.tar.gz to your Desktop

 

Double click imap-2007f.tar.gz to expand the archive.

 

Fix the makefile. Open imap-2007f/Makefile and comment out line 422 that reads:

EXTRACFLAGS="$(EXTRACFLAGS) -DMAC_OSX_KLUDGE=1" \

 

by inserting a # pound symbol at the start of the line so that it reads:

#EXTRACFLAGS="$(EXTRACFLAGS) -DMAC_OSX_KLUDGE=1" \

 

Build the software with:

make oxp SSLDIR=/usr SSLCERTS=/System/Library/OpenSSL/certs

 

Create a place to store the server:

sudo mkdir -p /usr/local/libexec

 

Copy the server into place:

sudo mv ipopd/ipop3d /usr/local/libexec

 

Create a PAM authentication module:

sudo cp /etc/pam.d/ftpd /etc/pam.d/pop

 

Create a self-signed certificate (this is all on one line):

sudo openssl req -new -x509 -nodes -out /System/Library/OpenSSL/certs/ipop3d.pem -keyout /System/Library/OpenSSL/certs/ipop3d.pem -days 3650

 

Fill in the prompts for your local mail server.

 

Create launchd config files

sudo touch /Library/LaunchDaemons/edu.washington.pop3.plist

sudo vi /Library/LaunchDaemons/edu.washington.pop3.plist

 

Enter the following content:

Label

edu.washington.pop3

ProgramArguments

/usr/local/libexec/ipop3d

Sockets

Listeners

Bonjour

SockServiceName

pop3

SockType

stream

inetdCompatibility

Wait

 

Do the same for /Library/LaunchDaemons/edu.washington.pop3s.plist. changing Label to edu.washington.pop3s and SockServiceName to pop3s.

 

Load the launchd config files:

sudo launchctl load -w /Library/LaunchDaemons/edu.washington.pop3.plist

sudo launchctl load -w /Library/LaunchDaemons/edu.washington.pop3s.plist

 

Test your POP server:

openssl s_client -connect localhost:995

CONNECTED(00000003)

depth=0 <certificate stuff…>

emailAddress=

verify error:num=18:self signed certificate

verify return:1

depth=0 <certificate stuff…>

emailAddress=

verify return:1

Certificate chain

0 s:<certificate stuff…>

i:<certificate stuff…>

Server certificate

—–BEGIN CERTIFICATE—–

—–END CERTIFICATE—–

subject=<certificate stuff…>

emailAddress=

issuer=<certificate stuff…>

emailAddress=

No client certificate CA names sent

SSL handshake has read 1037 bytes and written 328 bytes

New, TLSv1/SSLv3, Cipher is AES256-SHA

Server public key is 1024 bit

Secure Renegotiation IS supported

Compression: NONE

Expansion: NONE

SSL-Session:

Protocol : TLSv1

Cipher : AES256-SHA

Session-ID: <something…>

Session-ID-ctx:

Master-Key: <something else…>

Key-Arg : None

Start Time: 1311510626

Timeout : 300 (sec)

Verify return code: 18 (self signed certificate)

+OK POP3 localhost 2007f.104 server ready

user

+OK User name accepted, password please

pass

+OK Mailbox open, messages

quit

+OK Sayonara

read:errno=0

 

Edit the launchd config file for postfix:

sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist

 

Add the following:

KeepAlive

 

after the lines:

Label

org.postfix.master

 

 

And remove the following:

-e

60

 

Restart postfix master:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.postfix.master.plist

sudo launchctl load -w /System/Library/LaunchDaemons/org.postfix.master.plist

 

Test your SMTP server:

t**elnet 25**

Trying fec0:0:0:fea9::1…

Connected to .

Escape character is '^]'.

220 pele.local ESMTP Postfix

EHLO

250-

250-PIPELINING

250-SIZE 10485760

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250-DSN

250-BINARYMIME

250 CHUNKING

 

Hold down the control key and type ]:

Enter the following at the telnet> prompt:

 

telnet> quit

 

Construct a test message:

From: @

To: @

Subject: This is a local test

 

This is a local test of the mail system.

 

Send your test message:

cat test.txt | sendmail -t

 

Setup Apple Mail to connect to:

Incoming Mail Server:

User Name:

Password:

 

Outgoing Mail Server SMTP:

Use only this server: checked

 

Advanced:

Port: 995

Use SSL checked

Authentication: Password

 

 

Check your e-mail in Apple Mail. Accept the certificate.

 

Scroll to Top