- How To Install Apache On Macos Catalina
- Install Apache On Mac Catalina Download
- Install Apache On Mac Catalina Update
- Install Apache On Mac Catalina Os
- Install Apache Mysql Php On Macos Catalina 10.15
- Install Apache On Mac Catalina Free
If you want to run a server on your macOS Catalina, or you recently updated to Catalina, you might need to re-configure your system, follow the below instructions.
Updates
For macOS Big Sur (11.0.x) setup guide, please check out Setting Up Your Local Web Server on macOS Big Sur 11.0.1 (2020)| MAMP | macOS, Apache, MySQL, PHP
In this tutorial we will learn to install Apache, MySQL, PHP on macOS Mojave 10.14. Apple released the new macOS Mojave 10.14 on 24th September 2018 and it includes Apache and PHP. We will be using the pre-installed Apache and PHP and we will download and setup MySQL database. For Catalina the original versions may have a suffix of mojave or be copied to a backup folder on the Desktop. Most of the time, configuring your system after updating Mac OS X is simply a matter of comparing the new and old configurations. This post will look at the differences in Apache, PHP, and MySQL between Mac OS X Mojave and macOS.
Start the Apache Server
You can start off the built-in Apache server by following the below steps.
Open Terminal from your Application folder or type “Terminal” in the Spotlight Search.
Type sudo apachectl start
and press enter.
Open any of your favorite browser.
Type localhost
or 127.0.0.1
in the address bar
If Apache server is started, you should see the below:
Create Sites
directory
Let’s create a Sites
directory under username
folder (username is your mac login name) This directory is going to be the document root.
1. Go to Mac HDD
> Users
> [your account folder]
2. Create folder with the name Sites
. When the folder is created, it will generate a folder with compass image on the folder.
Create username.conf
file
To be able to recognize the files putting into Sites directory, username.conf needed to be setup. This is going to be your document root.
Type whoami
and press enter. Note down the name. (that is your account name / username)
Create a username.conf file based on the account name showed up when you type whoami
. e.g. If your username is developer
the filename will be developer.conf
.
Type cd /etc/apache2/users
and press enter.
How To Install Apache On Macos Catalina
Type ls
and press enter. Check if there is existing username.conf
(username is your account name)
If there is an existing username.conf, make a backup copy by typing sudo cp username.conf username.conf.bakup
.
Type sudo nano username.conf
and press enter. Note: “username” will be your account name. e.g. developer.conf
.
Copy and paste the following configuration.
Press Control+o
and press enter to save the file.
Press Control+x
to exit the nano editor
Configure the httpd.conf
file
Open Terminal from your Application folder or type “Terminal” in the Spotlight Search.
Type cd /etc/apache2
and press enter.
Type sudo cp httpd.conf httpd.conf.bak
and press enter. (This step is optional if you want to keep the copy of original config file)
Type sudo nano /etc/apache2/httpd.conf
and press enter.
(httpd.conf file will be opened in terminal’s editor. – in this case nano editor)
Press Control+w
and type LoadModule authz_core_module
and press enter. Uncomment the following modules. #
means it is commented out. Remove the #
in front of each module. If you cannot find the module, use the Control+w
and type in the module name you are searching for.
Uncomment the following line for the User home directories.
Replace the below two lines with your username document root. (You can comment those two lines by putting #
in front of them.
Replace with the following:
Note: USERNAME needs be replaced with your username (e.g. developer)
Press Control+w
and type AllowOverride None
.
Replace AllowOverride None
to AllowOverride All
Your DocumentRoot
configuration in httpd.conf
will look like below:
Press Control+o
and press enter to save the file.
Press Control+x
to exit the nano editor.
Configure the httpd-userdir.conf
file
Type cd /etc/apache2/extra
and press enter.
Type sudo cp httpd-userdir.conf httpd-userdir.conf.bakup
and press enter. (This step is optional if you want to keep the copy of original config file)
Type sudo nano httpd-userdir.conf
and press enter.
Uncomment the following line.
Press Control+o
and press enter to save the file.
Press Control+x
to exit the nano editor.
Type sudo apachectl restart
. To take effect all the changes made in the Apache config file.
Enable the PHP
Mac has built-in PHP. You just need to enable the PHP from the Apache’s config file. Follow the below steps.
1. Open Terminal from your Application folder or type “Terminal” in the Spotlight Search.
2. Type cd /etc/apache2
and press enter.
3. Type sudo nano /etc/apache2/httpd.conf
and press enter.
(httpd.conf file will be opened in terminal’s editor. – in this case nano editor)
4. Press Control+w
to bring up a search option.
5. Search for php
and press enter.
You will see the following:
#
means, the line is commented out.
6. Remove the #
in front of LoadModule php7_module libexec/apache2/libphp7.so
7. Press Control+o
and press enter to save the file.
8. Press Control+x
to exit the nano editor
9. Type sudo apachectl restart
. To take effect all the changes made in the Apache config file.
Create a phpinfo()
page
To try out PHP is working on your system, create a phpinfo() file and load it on the browser.
Open Terminal from your Application folder or type “Terminal” in the Spotlight Search.
Type cd ~/Sites/
and press enter.
Type sudo nano phpinfo.php
and press enter. To create a phpinfo.php file. And it will bring you to nano editor within Terminal.
Put the following code:
Press Control+o
and press enter to save the file.
Press Control+x
to exit the nano editor.
Go to browser and type the following in the address bar.
You should see a page below if the PHP module is successfully activated.
Setting up the MySQL Server
Go to https://dev.mysql.com/downloads/mysql/
Download the DMG installer.
Double click the installer and follow the installation steps in the wizard.
Once the installation is complete, you should have the MySQL icon in the System Preferences.
You can stop and start the MySQL server.
References
Thank you to following articles. I used the below articles as a reference.
Latest Posts
As you can see, since the update on Mac OS X 10.7 Lion, the system has lost the ability to enable an FTP server for sharing files and folders. It’s unclear why Apple removed the graphical interface for enabling FTP sharing, but you can still start a local FTP (or SFTP) server on macOS using the command line.
If you use the command line, you probably noticed that the latest versions of macOS do not have FTP file transfer protocol.
By default, FTP is not installed in the latest versions of the system, but this does not mean that you cannot install the protocol yourself. Modern versions of macOS use SFTP instead of FTP. SFTP has more secure encryption.
However, some users still prefer FTP. If you don’t need FTP, then there’s no reason to install it.
How to Install FTP in macOS
If you still haven’t installed Homebrew on a Mac, you need to do this before proceeding with the instructions below.
We will do this by installing inetutils. And this is done through Homebrew. If you haven’t Homebrew in your system, you can take script for Homebrew installing here.
Installation Using inetutils
The inetutils file contains: FTP, FTP server, telnet and telnet server, as well as rsh, rlogin, tfp servers and clients, etc. If you need FTP protocol, it will not hurt to install the entire set.
To do this, use the following command:
When Homebrew finishes installing inetutils, you can run the FTP command as usual. For example, you can connect to the gnu.org server to check that everything worked out.
One of the advantages of this method is that you also get other useful tools in the kit, and you will not need to install them manually.
How to Start FTP and SFTP Server in macOS
Naturally, it is possible to download a separate server and many do, but why, if the mac out of the box already has a built-in ftp / sptp server, which is enough for most tasks. Simply, the built-in server is disabled by default and we just need to enable it. This is what we will do.
Start FTP server in macOS
First, start the Terminal (/Applications/Utilities/Terminal.app) and run the following command:
Check if the server is working with the ftp localhost command. If you see something similar in the terminal window:
So everything turned out and the server works. To connect to the server, use your account or create a new one, especially for ftp connections (which will be more correct from a security point of view). To access files on the server, use the “connect to server” command in the Finder or using any ftp client.
Start SFTP server in macOS
As you know, the FTP server transmits data in unencrypted form and, as a result, for security reasons, it is not very reliable.
To exchange information securely, you need to use an SFTP server, for this:
- If, for security reasons, you still need to encrypt the transmitted data, then enter the “System Preferences”->“Sharing”;
Install Apache On Mac Catalina Download
- Check the box next to “Remote Login”;
- In the “Allow access” block, it is advisable to select the “Only these users” option and Specify your users.
You can also test the operation of this server using with command:
Install Apache On Mac Catalina Update
ATTENTION!!!
FTP and SFTP servers may conflict with each other and it is not recommended to keep them enabled at the same time.
Server Shutdown
Install Apache On Mac Catalina Os
The built-in SFTP server is disabled by unchecking the Remote login option in the system settings.
You can disable the FTP server in the terminal using the command:
Install Apache Mysql Php On Macos Catalina 10.15
Conclusion
Install Apache On Mac Catalina Free
If this is the first login to the server, then the client will offer to remember the host to which the connection is made. You can confirm this action by typing the word “yes” in the console and pressing the “Enter” key. Otherwise, type “no” and press “Enter”.
Next, you need to enter a password, if all the data has been entered correctly, the client will successfully connect to the server.