Recommend switching to Docker
Elated, I moved back to the System Preferences for MySQL, and after happy feelings at seeing the two green dots (indicating success), I tried to stop MySQL by clicking on the button labelled 'Stop MySQL Server'. In this tutorial, I will show you how to setup/install Apache, PHP, and MySQL on macOS Catalina. Open the Terminal app and switch to the root user so you can run the commands in this post without any permission issues: 0001. Enable Apache on macOS.
I finally switched to using Docker for local development on macOS. While the following tutorial works for macOS Catalina, it has limitations. I recommend following my latest tutorial on installing Apache, MySQL, and PHP on macOS using Docker.
Note: This post assumes you followed installing Apache, PHP, and MySQL on Mac OS X Mojave and have since upgraded to macOS Catalina. If you did not follow the original post, you should follow installing Apache, PHP, and MySQL on macOS Catalina.
Bug #101529: Despite notice that Catalina builds will run on Mojave, 8.0.22 will not: Submitted: 9 Nov 20:53: Modified: 11 Nov 7:44: Reporter: Toby Simmons. The MySQL JDBC Driver makes it easy to access live MySQL data directly from any modern Java IDE. After configuring the connection, explore the tables, views, and stored procedures provided by the MySQL JDBC Driver. These constructs return live MySQL data that developers can work with directly from within the IDE. Bug #101711: MySQL Workbench 8.0.22 and MacOS Catalina 10.15.7: Apple cannot check malicious: Submitted: 22 Nov 2020 18:19: Modified: 22 Nov 2020 18:46.
When Mac OS X upgrades it overwrites previous configuration files. However, before doing so it will make backups. 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 Catalina.
Updating Apache
Mac OS X Mojave and macOS Catalina both come with Apache pre-installed. As noted above, your Apache configuration file is overwritten me when you upgrade to macOS Catalina.
There were a few differences in the configuration files. However, since both Mojave and Catalina run Apache 2.4, you could simply backup the configuration file from Catalina and overwrite it with your Mojave version.
However, I encourage you to stay up-to-date. As such, you should take the time to update Catalina's Apache configuration. First, create a backup and compare the two configuration files for differences.
Now edit the Apache configuration. Feel free to use a different editor if you are not familiar with vi.
Uncomment the following line (remove #
):
In addition, uncomment or add any lines you noticed from the diff
above that may be needed. For example, I uncommented the following lines:
Finally, I cleaned up some of the backups that were created during the macOS Catalina upgrade. This will help avoid confusion in the future.
Note: These files were not changed between versions. However, if you changed them, you should compare the files before running the commands.
Restart Apache:
Updating PHP
Mac OS X Mojave came with PHP version 7.1 pre-installed. This PHP version has reached its end of life. macOS Catalina comes with PHP 7.3 pre-installed. If you added any extensions to PHP you will need to recompile them.
Also, if you changed the core PHP INI file it will have been overwritten when upgrading to macOS Catalina. You can compare the two files by running the following command:
Note: Your original file may note be named something else. You can see which PHP core files exist by running ls /etc/php.ini*
.
I would encourage you not to change the PHP INI file directly. Instead, you should overwrite PHP configurations in a custom PHP INI file. This will prevent Mac OS X upgrades from overwriting your PHP configuration in the future. To determine the right path to add your custom PHP INI, run the following command:
Note: It appears Catalina does not include the PHP Zip extension. This is a popular extension used by many packages. This was one of the reasons I switched to using Docker.
Updating MySQL
MySQL is not pre-installed with Mac OS X. It is something you downloaded when following the original post. As such, the macOS Catalina upgrade should not have changed your MySQL configuration.
Find this interesting? Let's continue the conversation on Twitter.
PREREQUISITES:
In order to follow this guide, you should have a Mac computer with the Catalina OS installed.
I was using for several years MAMP, Fywheel, as well as package managers like brew, and all work pretty well, but why not using the preinstalled Apache and PHP that is shipped in almost all macOS?
In this tutorial, I will show you how to setup/install Apache, PHP, and MySQL on macOS Catalina.
Open the Terminal app and switch to the root user so you can run the commands in this post without any permission issues:
Enable Apache on macOS
Mysql Workbench Catalina Download
Check if works by accessing:
http://localhost
Enable PHP for Apache
First, let’s make a backup of the default Apache configuration
Edit the Apache configuration
Uncomment the following line
Restart Apache:
You can verify PHP is enabled by creating a phpinfo() page in your DocumentRoot.
The default DocumentRoot for macOS Catalina is /Library/WebServer/Documents. In order to verify this, we run the command below to find out our Apache configuration.
Create the phpinfo() page in your DocumentRoot:
Verify PHP by accessing http://localhost/phpinfo.php
Customizing PHP settings (php.ini)
MacOS’ PHP uses a default php.ini file based on /private/etc/php.ini.default.
To customize your PHP environment, if a php.ini file doesn’t already exist at /private/etc/php.ini, copy the default template to create a main php.ini file:
Make any changes you wish to php.ini and restart apache to reload all configuration files:
If you were to run phpinfo() in a PHP file from the web server, you should now see that the Loaded Configuration File property now has the value /etc/php.ini.
A very common tweak to the default PHP configuration is to allow larger file upload sizes. The post_max_size and upload_max_filesize properties are only a few megs by default. These limits can be raised as you see fit.
Many developers also tweak the max_execution_time, max_input_time, and memory_limit settings depending on their project.
Always remember to restart apache after making changes to your PHP configuration.
Install MySQL on macOS Catalina
Download and install the latest MySQL version for your macOS.
Setup
Open a new terminal and run the code below this will update the mysql path on your ~/.profile
Please run mysql_secure_installation to make your MySQL secured
Recommended setup:
Strong Password? Yes
Change the root password? Yes
Remove anonymous users? yes
Disallow root login remotely? Yes
Remove test database? Yes
Reload privileges tables now? Yes
We can set a command shortcut for mysql:
Now, to access mysql console, we can run below short command:
Useful mysql commands
Connect PHP and MySQL
Create symlink to ensure PHP and MySQL can communicate each other.
Edited my Apache Configuration:
Uncommented the following lines
Virtual Hosts
Edit the Apache configuration file:
Add the below line after this included #Include /private/etc/apache2/extra/httpd-vhosts.conf
Create the apache2 vhosts directory.
Create the default virtual host configuration file.
Add the following configuration:
The default virtual host was created for when the Apache web server can’t find a virtual host, it will use this configuration. By prefixing this file with an underscore, Apache will include it first.
Now we can create our first virtual host. The example below contains the virtual host configuration for my test site.
Create the virtual host configuration file:
Catalina Mysql Path
Add the following configuration:
This VirtualHost configuration allows me to access my site from http://nuno-test.test for local development.
The final step is to restart Apache:
Test our apache configuration/strong>
Start, Stop, Restart and test Apache server config
I know it is a little bit daunting but I promise that we’ll never come back to this nasty lengthy configuration file again. Four simple commands are everything that we need to remember from now on. Start, stop, restart and configuration test.
Mapping our vhosts on macOS hosts file
Add your virtual host to the bottom of the file. It should match the value you used for the ServerName configuration.
Flush macOS DNS cache:
Permissions
You may receive 403 Forbidden when you visit your local site. This is likely a permissions issue. Simply put, the Apache user (_www) group (_www) needs to have access to read, and sometimes write, to your web directory.
Mysql Catalina
Conclusion
Mysql Catalog Update
By using the macOS preinstalled Apache and PHP we can avoid installing extra software on our macOS which sometimes could lead us to conflicts/errors/miss configuration on our Mac Operating system.