Install PhpMyAdmin on Mac

This article covers how to install PhpMyAdmin on Mac OS X. PhpMyAdmin is a software tool written in PHP to manage and administer MySQL databases. It supports not only MySQL, but also MariaDB and Drizzle databases. PhpMyAdmin supports a variety of database operations such as managing databases, tables, columns, relations, indexes, users, and permissions.

This article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.

How to Install PhpMyAdmin on Mac OS X

To install PhpMyAdmin, download the latest version.

Unzip the file and rename the folder to ‘phpmyadmin.’

Move the ‘phpmyadmin’ folder to ‘/usr/local/phpmyadmin.’

$ sudo mv phpmyadmin /usr/local/phpmyadmin

Copy the config.sample.inc.php to config.inc.php.

$ cd /usr/local/phpmyadmin
$ sudo cp config.sample.inc.php config.inc.php

Create a config file in ‘/etc/apache2/other.’

$ sudo touch /etc/apache2/other/phpmyadmin.conf

Edit the config file.

$ sudo nano /etc/apache2/other/phpmyadmin.conf

Add the following:

Alias /phpmyadmin /usr/local/phpmyadmin
<Directory /usr/local/phpmyadmin>
    Options Indexes
    Order allow,deny
    Allow from all
</Directory>

Restart Apache

$ sudo apachectl restart

Finally, access PhpMyAdmin from your browser. Example: http://localhost/phpmyadmin

Install MySQL on Mac

This article shows you how to install MySQL on the Mac OS X. MySQL is an open-source relational database management system used in majority of websites on the Internet. MySQL works on many platforms including Windows, Mac and many flavors of the Linux OS.

This article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.

How to Install MySQL on Mac OS X

First, download the MySQL dmg archive for the Mac OS.

Install the following 3 items:

  1. MySQL package
  2. MySQL Startup Item package
  3. MySQL Preferences Pane

Add the MySQL path to your existing path so you can invoke MySQL commands from anywhere.

$ export PATH=/usr/local/mysql/bin:$PATH

Secure the database. You’ll be prompted to provide a new MySQL password.

$ sudo mysql_secure_installation

Make sure MySQL is connected to Apache and PHP.

cd /var 
sudo mkdir mysql 
cd mysql 
sudo ln -s /tmp/mysql.sock mysql.sock

Access MySQL from the Terminal. Provide your password when prompted.

$ mysql -u root -p

Once logged in, you can check the databases just to be sure you’re connected.

mysql> show databases;
exit;

Install PHP on Mac

This article will show you how to install PHP on the Mac. By default, Apache and PHP are already installed on the Mac, although both are not activated. We must first enable Apache. Once you’ve Apache is enabled, you can then proceed in activating PHP.

This article is part of a series of articles on how to manually install Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.

How to Install PHP on Mac OS X

PHP is already installed. We just have to enable it. Edit the ‘/etc/apache2/httpd.conf‘ file.

$ sudo nano /etc/apache2/httpd.conf

Uncomment or delete the ‘#’ sign for the line that contains the text below.

LoadModule php5_module libexec/apache2/libphp5.so

Restart Apache

$ sudo apachectl restart

Place a index.php file that contains the following in your web server root.

<?php phpinfo(); ?>

If you see PHP info and stats, that means PHP is working! If you see the code, it means PHP is not working.

Apache Virtual Host on Mac

Creating an Apache virtual host on your Mac is quite easy. Assuming you already have Apache installed and running on your Mac, you will now have to decide whether to serve your pages from the default web root, or create your own virtual host, and serve your pages from an alternate location.

This article is part of a series of articles on how to manually install MAMP or Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.

Create an Apache Virtual Host on Mac OS X

Edit the /etc/apache2/httpd.conf file using the nano editor.

$ sudo nano /etc/apache2/httpd.conf

Look for the text ‘# Virtual hosts’ located at the end of the file. Uncomment by removing # from the line that says:

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

Save file and exit. If your not familiar with nano, it’s Ctrl-O for save, and Ctrl-X for exit.

Now edit the https-vhosts.conf file.

$ sudo nano /private/etc/apache2/extra/httpd-vhosts.conf

Append the following at the end of the file:

<VirtualHost *:80>
	DocumentRoot "/Users/Ulysses/Sites/"
	ServerName ulysses.dev
	ErrorLog "/private/var/log/apache2/ulysses.dev.local-error_log"
	CustomLog "/private/var/log/apache2/ulysses.dev.local-access_log" common
	<Directory "/Users/Ulysses/Sites/">
		AllowOverride All
		Order allow,deny
		Allow from all
	</Directory>
</VirtualHost>

In this example, I am using an alternate web root located at ‘/Users/Ulysses/Sites/.’ In addition, I’m also using a made-up domain called ‘ulysses.dev.’ I used .dev because it’s not a real top level domain or TLD. There won’t be a conflict with a real existing domain on the Internet. You can use any domain or TLD that you like.

The final step. Edit your hosts file to add your domain. This step is very important since we are using a made-up domain that doesn’t exist. By editing our hosts file, we are spoofing our system that a host does exist.

$ nano /private/etc/hosts

Add the following domain at the end of the line. 127.0.0.1 is the loopback address of your system.

127.0.0.1  ulysses.dev

Save file and exit.

Restart Apache

$ sudo apachectl restart

From the terminal ping your domain.

$ ping ulysses.dev

Write permissions

The Apache user on the Mac is _www and is part of the staff group. To make the Sites folder writeable to the Apache _www user, perform the following commands from the Terminal.

cd /Users/Ulysses
$ sudo chown -R _www:staff Sites
$ sudo chmod -R 755 Sites

Finally, open up your browser and access your domain. In this example, http://ulysses.dev.

Install Apache on Mac

This article will show you how to install Apache on the Mac OS. This is ideal if you want to use your Mac desktop or laptop as your development environment, a place where you can test code, scripts, themes, plugins without affecting your production environment.

This article is part of a series of articles on how to manually install MAMP or Apache, PHP, MySQL on the Mac OS. Installing the popular MAMP application is as simple as installing any other application on the Mac, but it will not give you any valuable learning experience, nor will you have complete control of your development environment. I recommend manually installing the individual applications to maximize your learning experience.

Apache is the widely popular web server that runs on multiple platforms including Linux, Mac OS and Windows. Some people might be surprised to know that Apache is already installed and included on the latest Mac OS X Mavericks. All you need to do is turn it on. You can do so by accessing the Terminal and typing the following:

How to Install Apache on Mac OS X

Start Apache

$ sudo apachectl start

You should be able to see ‘It works!‘ if you access ‘http://localhost‘ from your Safari, Chrome or Firefox browser.

In addition, you can also stop and restart Apache using the commands below.

Stop Apache

$ sudo apachectl stop

Restart Apache

$ sudo apachectl restart

By default, the web root for the Apache web server is located at ‘/Library/WebServer/Documents/.’ In the directory, you’ll find a document called ‘index.html.en‘ which contains the code that displays ‘It works!

<html><body><h1>It works!</h1></body></html>

It works!

Finally, you can now move your HTML pages to the ‘/Library/WebServer/Documents/‘ folder to serve pages. The other option is to create a virtual host within Apache which I will cover in my next article.