In my case, all my files were under my local ~/Documents directory. You can change permissions with the command: chmod 755 some_directory/ For now though, the easiest thing to do is ensure your web directory has permissions of 755. If you are not familiar with permissions, read more. Simply put, the Apache user ( _www) needs to have access to read, and sometimes write, your web directory. You may receive 403 Forbidden when you visit your local site. Note: You will need to create a new VirtualHost and edit your hosts file each time you make a new local site. I run the following to clear the local DNS cache: dscacheutil -flushcache vi /etc/hostsĪdd the following line to the bottom: 127.0.0.1 jason.local In order to access, you need to edit your hosts file. This avoids conflicts with any real extensions and serves as a reminder I’m in my local environment. For ease of development, I also configured some custom logs. The second VirtualHost points to my dev workspace and I can access it directly from. The first VirtualHost is important as it behaves like the default Apache configuration and used when no others match. The first VirtualHost points to /Library/WebServer/Documents. ĭocumentRoot "/Library/WebServer/Documents"ĭocumentRoot "/Users/Jason/Documents/workspace/dev"ĮrrorLog "/private/var/log/apache2/jason.local-error_log"ĬustomLog "/private/var/log/apache2/jason.local-access_log" common Here is an example of VirtualHosts I’ve created. Uncomment the following line: Include /private/etc/apache2/extra/nf To do so, we’ll edit the Apache Configuration again. To run sites individually you need to enable VirtualHosts. Not ideal for a local development environment. However, all of your sites would have URLs like to /Library/WebServer/Documents/somesite. You need to ensure PHP and MySQL can communicate with one another. While this isn’t necessary, it’s good practice. Note: You will need to open a new Terminal window or run the command above for your path to update. Instead, I updated my path to include /usr/local/mysql/bin. However there are other commands that are helpful such as mysqldump. The README also suggests creating aliases for mysql and mysqladmin. Optionally, you can enable MySQL to start automatically.Uncomment the following line (remove #): LoadModule php5_module libexec/apache2/libphp5.so Feel free to use TextEdit if you are not familiar with vi. This is good practice and serves as a comparison against future versions of Mac OS X. Verify It works! by accessing Enable PHP for Apacheįirst, make a backup of the default Apache configuration. Note: Prior to Mountain Lion this was an option for Web Sharing in System Prefrences → Sharing. sudo su -Įnable Apache on Mac OS X apachectl start In the end, you only install MySQL then simply turn everything on.įirst, open Terminal and switch to root to avoid permission issues while running these commands. Furthermore, Apache and PHP are included by default. So all of these technologies install easily on Mac OS X. It is important to remember Mac OS X runs atop UNIX. Personally, the choice to do it myself has proven invaluable. But they forego the learning experience and, as most developers report, eventually break. These packages help get you started quickly. I am aware of the several packages available, notably MAMP. This post serves as much for my own record as to outline how to install Apache, MySQL, and PHP for a local development environment on Mac OS X Mountain Lion. Each version of Mac OS X having some minor difference. I have installed Apache, PHP, and MySQL on Mac OS X since Leopard.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |