- CouchDB and PHP Web Development Beginner’s Guide
- Tim Juravich
- 580字
- 2021-08-13 18:22:50
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.
- Use Finder to navigate to the following folder:
/etc/apache2
. - Locate and open a file named
httpd.conf
in your text editor. - Look through the file, and find this line (it should be line
114):
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so
- 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
- 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>
- Alter the line of code that says
AllowOverride None
and change it to sayAllowOverride All
. The resulting section should look as follows:<Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Allow from all </Directory>
- 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
- Alter the line of this code that says
AllowOverride None
and change it to readAllowOverride 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
- Open Terminal.
- 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.
- ServiceNow Application Development
- Learning Docker
- Oracle Database In-Memory(架構與實踐)
- 從程序員到架構師:大數據量、緩存、高并發(fā)、微服務、多團隊協(xié)同等核心場景實戰(zhàn)
- 機械工程師Python編程:入門、實戰(zhàn)與進階
- Java:High-Performance Apps with Java 9
- Couchbase Essentials
- 軟件測試綜合技術
- Instant Debian:Build a Web Server
- 零代碼實戰(zhàn):企業(yè)級應用搭建與案例詳解
- C語言程序設計實踐
- 從零學Java設計模式
- Python面試通關寶典
- Offer來了:Java面試核心知識點精講(框架篇)
- Android初級應用開發(fā)