官术网_书友最值得收藏!

Time for action — further configuration of Apache

mod_rewrite will allow us to rewrite the requested URLs on the fly, which will help us build an application with clean URLs. The rewriting itself is handled in another Apache configuration file called .htaccess, which we will touch on in Chapter 4, Starting Your Application. In the following section, we'll configure Apache, so that mod_rewrite is enabled.

  1. Use Finder to navigate to the following folder: /etc/apache2.
  2. Locate and open a file named httpd.conf in your text editor.
  3. Look through the file, and find this line (it should be line 114):
    #LoadModule rewrite_module libexec/apache2/mod_rewrite.so 
    
  4. Uncomment the line by removing the hash (#) symbol. It's possible that your system is already configured to enable mod_rewrite. Regardless, make sure it matches the following code:
    LoadModule rewrite_module libexec/apache2/mod_rewrite.so 
    
  5. Look through the file, and find this chunk of code (it should go from line 178-183):
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
    </Directory>
    
  6. Alter the line of code that says AllowOverride None and change it to say AllowOverride All. The resulting section should look as follows:
    <Directory />
    Options FollowSymLinks
    AllowOverride All 
    Order deny,allow
    Allow from all
    </Directory>
    
  7. Keep scrolling through the file until you find this chunk of code (should go from line 210-215):
    #
    # AllowOverride controls what directives may be placed in #.htaccess files.
    # It can be —All—, —None—, or any combination of the keywords:
    # Options FileInfo AuthConfig Limit
    #
    AllowOverride None
    
  8. Alter the line of this code that says AllowOverride None and change it to read AllowOverride All. The resulting section should look as follows:
    #
    # AllowOverride controls what directives may be placed in #.htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    # Options FileInfo AuthConfig Limit
    #
    AllowOverride All
    
  9. Open Terminal.
  10. Restart Apache by running the following command:
    sudo apachectl restart 
    

What just happened?

We just configured Apache so that it can operate more freely and include the ability to rewrite URLs using the mod_rewrite module. We then changed the configuration of AllowOverride from None to All. AllowOverride tells the server what to do when it finds the .htaccess file. With this being set to None, the .htaccess file is ignored. Changing the setting to All allows settings to be overridden in an .htaccess file. This is exactly what we'll do as we start building out our application in Chapter 4.

Our web development setup is complete!

We now have everything set up for us to create standard web applications. We have Apache handling requests. We have PHP connected and responding to calls from Apache, and we have our text editor ready for any code that we can throw at it.

There are still a few pieces missing for us to have a complete development environment. In the next section, we will install CouchDB as our database.

Installing CouchDB

In this section, we will install CouchDB 1.0 onto your machine and get it prepared for development. There are a variety of ways to get CouchDB on your machine, so if you have issues with the following install process, please reference CouchDB's website here: http://wiki.apache.org/couchdb/Installation.

Homebrew

In order to install the rest of the components that we will use in this book, we will use a utility called Homebrew. Homebrew is the easiest way to install the UNIX tools that Apple left out of OSX. Before we can use Homebrew to install other tools, we first need to install Homebrew.

主站蜘蛛池模板: 将乐县| 荔浦县| 汉寿县| 义乌市| 宁河县| 乐陵市| 石嘴山市| 平顶山市| 岳池县| 南投县| 垦利县| 遵义市| 卢龙县| 清徐县| 黄山市| 顺平县| 玉环县| 安溪县| 芜湖市| 土默特左旗| 滁州市| 开鲁县| 延长县| 美姑县| 聂荣县| 上蔡县| 阿城市| 南木林县| 黄陵县| 巴南区| 耿马| 白银市| 漯河市| 凉城县| 定日县| 当阳市| 庆城县| 嘉定区| 百色市| 务川| 嘉祥县|