In this tutorial we will learn to install Apache, MySQL, PHP on macOS Mojave 10.14.
A few of the examples of PHP & MySQL-based scripts are WordPress, Joomla, Magento, and Drupal. The latest version of MySQL is 8.0.19, released on 13 January 2020. However, there is still support of version 5.6.45, but it will end soon. Using the outdated version of MySQl that does not have any support is not smart. This release contains no functional changes and is published to align the version number with the MySQL Server 8.0.25 release. Read the full changelog DOWNLOAD MySQL Connector/NET 8.0.27 for Windows.
The -u username in the command represents your MySQL username. The -h mysqlserverip is the IP or the hostname of your MySQL server. The -p option prompts you to enter the password for the MySQL username. You should see an output similar to the one below: Connection to mysqlserverip 3306 port tcp/mysql succeeded! Installing version 8.0.19 MySQL community server and Workbench for MacOS. The current MySQL package for Mac OS X Mavericks (mysql-5.6.17-osx10.7-x8664 at the time of this writing) automatically creates a my.cnf during installation. It is located at /usr/local/mysql-5.6.17-osx10.7-x8664/my.cnf. Adapt your path according to your version. To uninstall MySQL and completely remove it (including all databases) from your Mac do the following: Open a terminal window Use mysqldump to backup your databases to text files!
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.
Lets go ahead and configure our LAMP stack development environment on macOS Mojave.
The new macOS Mojave comes with Apache pre-installed. All we have to do is switch it on.
Open Terminal using macOS Spotlight or go to /Applications/Utilities and open Terminal.
To check the version of Apache installed run the following command in the Terminal.
macOS Mojave comes with Apache/2.4.34.
To start Apache web server run the following command.
This command will start Apache server.
When you use
sudo in the terminal then you will be prompted to enter your admin password to proceed.
If you want to stop the Apache server then run the following command.
And to restart Apache server run the following command.
After starting Apache server go ahead and test it by opening a browser like Safari or Chrome and visit
You will get to see the following output in your browser.
In case you don't get to see the above output then run the following command to check the error.
This is the location in the computer file system from where the files are accessed when we visit the localhost in a browser.
Document Root is a directory where we put our website files.
On Mac we have two document root. One is at the system level and the other is at the user level.
System level document root
The system level document root in macOS Mojave is located in the following directory.
User level document root
For the user level we can create a directory called
Sites in user directory.
Run the following command to switch to the user home directory.
Now, run the following command to create the
For me the user document root path is the following.
Now, its time to create a
username.conf file which will help in configuring our document root.
Note! Replace the username with your username.
For example, my username is yusufshakeel so, my file is
whoami command in the terminal and it will tell you your username.
Open terminal and go to the following directory.
Now create the configuration file username.conf inside the users directory.
In the following example I am using vi editor. You can use other editors like vim or nano.
Press the i key to enter into INSERT mode. Now, type the following inside the file.
Don't forget to replace
YOUR_USER_NAME with your username.
Here is what I have written in my
Now, to come out of the INSERT mode press the Esc key. And to save the file and exit type the following :wq and hit Enter.
The permission of this file should be the following.
If not, then use the following command to change its permission.
Where, username is your username that you have set earlier.
Type the following command in the terminal and go to apache2 directory.
Inside this directory we have the
As a good practice we will make a backup copy of the
httpd.conf file by typing the following command in the terminal.
Now open the httpd.conf file using
vi and uncomment the following lines.
To uncomment the following lines remove the
# from the start of the line.
Mysql Community Server 5.7 Mac
Uncomment the following line for User home directories.
Now change the DocumentRoot.
Find the following lines and comment them by adding
# at the beginning of the line.
And add the following two lines below the commented lines.
Don't forget to replace
YOUR_USERNAME with your username.
And set the
AllowOverride None to
Your DocumentRoot should now look something like the following.
Now, come out of the INSERT mode by pressing the Esc key. And save and exit the file by typing :wq key and then Enter.
Now, we will make some changes in the httpd-userdir.conf file.
Type the following command in the terminal to go to the extra directory.
As a good practice we will first create a backup copy of the
httpd-userdir.conf file. Type the following command to create a backup copy.
Now open the file using
Uncomment the following line.
Now check that everything is configured properly by typing the following command in the terminal.
And then restart Apache using the following command.
macOS Mojave comes with PHP 7.1.x pre-installed.
To check the version of PHP in the Terminal type the following command.
Alright, type the following command in the terminal to go to apache2 directory.
Enter into INSERT mode by pressing the i key and uncomment the following line to run PHP 7 by removing the
# sign from the start of the line.
Now, save the changes and exit the file by typing :wq keys and hit Enter.
You can now restart Apache by running the following command.
index.php file inside the Sites directory by running the following command.
Now open this file in your favourite text editor or PHP IDE and write the following code.
http://localhost and you will get to see a similar output.
Download MySQL community server
Head over to mysql.com website and download the latest version of the MySQL Community Server.
Download and run the installer and follow the steps to install MySQL database on your Mac.
Download MySQL Database Server For Mac 8.0.19 Free
Set the root password when prompted and note it down.
To run MySQL server open System Preferences and go to MySQL.
Click on the Start MySQL Server button to start the server.
You will be asked to enter your admin password. Enter the password and the MySQL server will start running.
Mysql Community Download
To access your MySQL database tables you can either use phpMyAdmin, MySQL Workbench or Sequel Pro.
Download MySQL Database Server For Mac 8.0.19 Key
Mysql Community Server Mac
Alright, this brings us to the end of this tutorial. Hope this helped. Please share if you find this website useful. Have fun developing. See you in the next tutorial.
I previously explained how to install SQL Server on a Mac using the SQL Server for Linux Docker image.
Since then, Apple has released its M1 chip, which uses ARM architecture. This can cause a problem when trying to install SQL Server. The problem is, at the time of writing, SQL Server isn’t supported on the ARM architecture.
Fortunately, there’s an alternative.
The container image for Azure SQL Edge can be installed on the M1 Mac. Therefore, we can use that image instead of the SQL Server image.
Azure SQL Edge is an optimized relational database engine geared for IoT and IoT Edge deployments. It’s built on the latest versions of the SQL Server Database Engine, so you can use T-SQL code just like you would when using SQL Server. You can also the same tools to query Azure SQL Edge that you would use with SQL Server (such as SSMS, Azure Data Studio, etc).
Download MySQL Database Server For Mac 8.0.19 Full
In this article I install the Developer Edition of Azure SQL Edge on a Mac with the M1 chip.
Seeing as we’re installing SQL Edge via a Docker container, we need to have Docker installed.
If you don’t already have Docker, download and install it, as follows:
- Download Docker from the Docker website. Be sure to download the one for the M1 Mac (the button was called
Mac with Apple Chipwhen I downloaded it).
- Once downloaded, open the
.dmgfile and drag the Docker.app icon to your Applications folder as instructed.
- Launch Docker the same way you’d launch any other application (eg, via the Applications folder, the Launchpad, etc). When you open Docker, you might be prompted for your password. Go ahead and provide your password, as Docker needs this to run.
Install Azure SQL Edge
Now that Docker is installed, we can go ahead and install Azure SQL Edge. As mentioned, this uses the SQL Server Database Engine, and we can therefore use it to run T-SQL queries, etc, as if we were querying SQL Server.
Open a Terminal window and run the following command:
That pulls/downloads the container image to your local machine.
You can alternatively check the container options on the Docker website if you prefer.
Once the download is completed, run the following command to launch an instance of the Docker image you just downloaded:
Be sure to change
bigStrongPwd to a strong password of your choice. You can also change the value of the
--name parameter if you wish.
By default, the container is run with the Developer Edition. You can run the Premium Edition by adding
Download MySQL Database Server For Mac 8.0.19 Os
Check the Docker Container
We can use the following command to check whether the container is up and running:
This shows me that the container is in fact, up and running.
If, for some reason your container isn’t up and running, try the following command:
sqledge with the name of your container.
With the container up and running, we can now go ahead and connect to SQL Edge.
Connect to SQL Edge
You can now connect to your Azure SQL Edge installation by using the details provided when launching the Docker image.
Here’s a screenshot of connecting to Azure SQL Edge via Azure Data Studio:
Here’s how to install Azure Data Studio on a Mac.
Microsoft states that Azure Data Studio “currently does not support the ARM architecture” but I had no problem with installing it on my M1 Mac (i.e. with ARM architecture).
Run SQL Queries
Once connected to SQL Edge, you can create databases, run T-SQL queries, etc (T-SQL is SQL Server’s extension to SQL).
See my SQL tutorial to get up to speed with running SQL queries.
Supported Features in SQL Edge
I should mention that some SQL Server features are unsupported in SQL Edge. Azure SQL Edge supports a subset of the features supported SQL Server 2019 on Linux.
That said, SQL Edge does have some features that are unavailable in SQL Server (such as the
See Supported features of Azure SQL Edge on the Microsoft website for a full breakdown.