![]() You can do this in your terminal, or in Finder. Now, you need to create a Sites folder in the root of your home directory. Of course you will now need to restart your Apache with sudo apachectl restart to pick up the changes you just made to the configuration file. Change these to match your user account (replace your_user with your real username), with a group of staff: User your_user By default, apache runs as the user _About a third of the way down the nf file there are two settings to set the User and Group Apache will run under. Now we have the Apache configuration pointing to a Sites folder in our home directory. In that same block you will find an AllowOverride setting, this should be changed as follows: AllowOverride All User & Group This should also be changed to point to your new document root also: You also need to change the tag reference right below the DocumentRoot line. Search for the term DocumentRoot, and you should see the following line: DocumentRoot "/Library/WebServer/Documents"Ĭhange this to point to your user directory where your_user is the name of your user account: DocumentRoot "/Users/your_user/Sites" I prefer to use Sublime Text 3 with the commandline command subl, others will probably prefer vi but If you have never used a command line editor, try nano: $ sudo nano /etc/apache2/nf You can use whatever command line editor you are comfortable with, just realize this is a root-owned folder so you will need to use sudo to be able to edit and save the file. To do this, we will need to edit Apache's configuration file. As this is a development machine, let's assume we want to change the document root to point to a folder in our own home directory. By default, the document root is configured as /Library/WebServer/Documents. This is the folder where Apache looks to serve file from. The first thing we will want to do is to change the document root for Apache. If you cannot reach your site via might need to add an alias in your /etc/hosts file: 127.0.0.1 localhost. So start Apache now, and then try to reach your server in a browser by pointing it at your localhost, you should see a simple header that says It works!. To restart apache when you have made configuration changes, simply type: $ sudo apachectl restart To stop apache you would type: $ sudo apachectl stop To start up the web server, simply bring up the Terminal ( /Applications/Utilities/Terminal) and type: $ sudo apachectl start Using the terminal is a pretty scary prospect for many people, but there's no need to fear it. VirtualHostX is a pretty UI for controlling Apache, but you don't really need it.Īnother approach is simply to use the provided apachectl command from your terminal. This is a scaled down free version of the more powerful VirtualHostX. Not to fret! A simple Web sharing preference pane is available from. OS X 10.10 Yosemite comes with the Apache 2.4 pre-installed, but there is no longer a Web Sharing preference pane in the System Preferences. If you are a beginner developer, you will be better served using MAMP or MAMP Pro. IMPORTANT: This guide is intended for experienced web developers. Also updated to reflect OS X 10.10 Yosemite rather than Mavericks. This post was updated adding PHP 5.6 and how to update packages and switch to specific PHP versions. In the second blog post in this two-post series, we will cover MySQL, Apache virtual hosts, APC caching, and Xdebug installation. ![]() ![]() In this blog post, we will walk you through setting up and configuring the OS X built-in Apache and multiple PHP versions. It is times like these that people often look for an alternative approach, and luckily there is one, and it is relatively straight-forward to setup. However, there are times when MAMP Pro has slow downs, or out of date versions, or is simply behaving badly due to its restrictive system of configuration templates and non-standard builds. There are plenty of options for setting up your development environments, including the ever-popular MAMP Pro that provides a nice UI on top of Apache, PHP and MySQL. Yosemite Web Development Environment: Part 1ĭeveloping web applications on OS X is a real joy.
0 Comments
Leave a Reply. |