Install Apache Php Mysql Mac Catalina

  1. Install Apache Php Mysql Mac Catalina 2019
  2. Install Apache Php Mysql Mac Catalina Free
  3. Install Apache Php Mysql Mac Catalina
  4. Install Apache Php Mysql Mac Catalina Update

Installing Apache and PHP on macOS Catalina 10.15. The title of this page is quite 'misleading' as both Apache and PHP comes pre-bundled in macOS Catalina 10.15. We merely need to configure them. Press ⌘ + SPACE (Spotlight Search) and bring up the terminal.

There are many open source packages that require the 'AMP' stack comprising Apache, MySQL and PHP (hence 'WAMP' for Windows-Apache-MySQL-PHP and 'MAMP' for macOS-Apache-MySQL-PHP). Since macOS 10.12 Sierra already includes Apache 2.4 and PHP 5.6, here's how to add MySQL 5.7.

Install MySQL

To start, download MySQL Community edition for OS X as a .DMG archive.

I have upgraded my laptop from Mojave to Catalina. I do not use my laptop with any of the Apache Services. My current version of Apache httpd is: Apache/2.4.41. My security team told me that I need to update to Apache/2.4.42 or later. How do I do that? Can I run a simple command line that update the Apache httpd version to 2.4.42 or later. If you need to setup a MySQL Workbench, you can refer to Using MySQL Workbench on macOS Catalina (2019) If you are using macOS Catalina, check out Setting Up Your Local Server on macOS Catalina (2019) – MAMP – macOS, Apache, MySQL, PHP to setup your mac local web server.

Double click the archive, and then double click the .PKG installer. I accepted all defaults... and finally got to this screen: It's vital to a get a screenshot or copy the default password!

Once installed, go ahead and start up MySQL. Start the System Preferences > MySQLPreferences Pane and hit Start MySQL Server. You can choose if you want to automatically start MySQL with your mac.

Mysql
Change MySQL Root Password
Install

Next, login to the MySQL database and change the default root password. From the Terminal prompt start the MySQL client mysql. You will be prompted to enter the temporary password - enter what you captured during the installation previously:

If the password is correct, you'll get to the MySQL prompt e.g.:

Before you can do anything else, you are forced to change the temporary password. Run these commands to change the password to pass (or anything else you want):

I'm not concerned with security, so from now on, I simply log in with mysql -uroot -ppass. There is no space in the argument -ppass.

Apache
Create a Database

The application I was installing provided a SQL script to create tables, but first I had to create a database. The MySQL documentation describes this, but it's really simple. Running the mysql client again:

From now on, to start the MySQL client on the mydatabase database, the console command is mysql -uroot -ppass mydatabase.

Now, I can run the SQL commands provided by the application, which creates tables, indexes and seed data. Assuming the script is called batch-file.sql, this is how to 'run' it:

Review mysql.out to validate that all commands completed successfully and without errors.

Enable MySQL in PHP.INI

If you have not already started Apache with PHP, read my previous post to enable Apache and PHP.

Next, to enable a PHP library (driver) for MySQL. The MySQL PHP API documentation describes the three drivers to choose from - mysqli, PDO_MySQL or mysql (deprecated in PHP 5.5).

To do so, edit php.ini in /private/etc. You have to be administrator and the file is read-only by default.

There are other settings, but for me, the defaults are sufficient.

Once you re-start Apache (apachectl -k restart), you should check the MySQL driver settings. My previous post used a simple phpinfo.php file to do this:

Edit Bash Profile

Finally, if you're expecting to use the MySQL command line tools like mysql or mysqladmin often, you should edit your .bash_profile to permanently add MySQL to your PATH (as shown above), or create aliases to these commands as described in the MySQL installation guide:

Php
Conclusion

Once of the reasons I use a mac is that it's based on a UNIX core, and it's easy to get many open source packages running. Along with my previous post on enabling the 'built-in' Apache and PHP, this post describes getting MySQL up and running.

Before install your own apache server, make sure the apache server that came with Mac OS is shut down by issuing this command in the Termainal window

1. If you don’t have Xcode installed yet on your Mac, download and install it from the Apple App Store.

2. If you don’t have the home brew package manager installed yet, open up the terminal and type this command to get brew.

3. Install pcre, libtool, mysql, php56 and appache2.4 through brew package manager.

4. Open the apache 2.4 config file, and proceed to the following steps.

5. By default, Apache 2.4 listens to port 8080 instead of 80, find the line with Listen 8080 and change it to the following.

6. Load php56 module in the config file, add this line next to the last LoadModule in the config file. The path for libphp5.so might be different depending on the php version.

7. Find the line that has AddType and add the following line.

8. Find the line with DirectoryIndex and change it to the following

9. Find the following lines in the config file and uncomment them by removing the #

10. Find the lines with DocumentRoot and Directory, and change them to these. yourname is your user name that shows on the Terminal window.

Install Apache Php Mysql Mac Catalina 2019

11. Create an index.php file in /Users/yourname/sites with the code below that prints the phpinfo.

12. Start Apache server from the Terminal window.

13. Visit localhost in your browser and you should see a php info page.

To have launchd start homebrew/apache/httpd24 at login:

To have launchd start homebrew/php/php56 at login:

Install Apache Php Mysql Mac Catalina Free

To have launchd start mysql at login:

To start, stop and restart apache server.

Install Apache Php Mysql Mac Catalina

To install the php cli, add the php binary path to the .bash_profile

Install Apache Php Mysql Mac Catalina

Reconfigure .bash_profile and check php version

Where is the apache config file on mac os

Install Apache Php Mysql Mac Catalina Update

Check apache config info

Comments are closed.