Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your Mac comes with both an Apache Web Server and a build of PHP. It's one of the big reasons the platform is well loved by web developers.</p> <p>Since you're using Code Igniter, you'll want PHP 5, which is the default version of PHP shipped with 10.5. If you're on a previous version of the OS hop on over to <a href="http://www.entropy.ch/home/" rel="noreferrer">entropy.ch</a> and install the provided PHP5 package.</p> <p>Next, you'll want to turn Apache on. In the sharing preferences panel, turn on personal web sharing. This will start up apache on your local machine.</p> <p>Next, you'll want to setup some fake development URLs to use for your sites. I use the fake TLD .dev for this (ex. stackoverflow.dev). Edit your /etc/hosts file and add the following lines</p> <pre><code>127.0.0.1 www.example.dev 127.0.0.1 example.dev </code></pre> <p>This points the above URLs at your local machine. The last step is configuring apache. Specifically, enabling named virtual hosting, enabling PHP and setting up a few virtual hosts. If you used the entropy PHP package, enabling PHP will already be done. If not, you'll need to edit your http.conf file as described <a href="http://foundationphp.com/tutorials/php_leopard.php" rel="noreferrer">here</a>. Basically, you're uncommenting the lines that will load the PHP module.</p> <p>Whenever you make a change to your apache config, you'll need to restart apache for the changes to take effect. At a terminal window, type the following command</p> <pre><code>sudo apachectl graceful </code></pre> <p>This will gracefully restart apache. If you've made a syntax error in the config file apache won't restart. You can highlight config problems with</p> <pre><code>sudo apachectl configtest </code></pre> <p>So,with PHP enabled, you'll want to turn on NamedVirtualHosts. This will let apache respond to multiple URLs. Look for the following (or similar) line in your http.conf file and uncomment it.</p> <pre><code>#NameVirtualHost * </code></pre> <p>Finally, you'll need to tell apache where it should look for the files for your new virtual hosts. You can do so by adding the following to your http.conf file. NOTE: I find it's a good best practice to break out config rules like this into a separate file and use the include directive to include your changes. This will stop any automatic updates from wiping out your changes.</p> <pre><code>&lt;VirtualHost *&gt; DocumentRoot /Users/username/Sites/example.dev ServerName example.dev ServerAlias www.example.dev &lt;/VirtualHost&gt; </code></pre> <p>You can specify any folder as the DocumentRoot, but I find it convenient to use your personal Sites folder, as it's already been configured with the correct permissions to include files.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload