Configuring Zend Framework 2 with lighttpd
As a basis we use the ubuntu , but serves to any distribution, just know locate the configuration file lighttpd (lighttpd.conf)
Accessing lighttpd.conf
In ubuntu the file is located in / etc / lighttpd in other distributions.
Run command:
find / -name lighttpd.conf
Make sure that the mod_rewrite is active.
server.modules = (
"Mod_access"
"Mod_alias"
"Mod_compress"
"Mod_redirect"
# "Mod_rewrite"
)
Remove the ‘#’ back of the “mod_rewrite”, and voila! Ready a part.
Configuring mod_rewrite
On my server I use the mod_simple_vhost , but for those who do not use, simply remove the portion of the $ HTTP ..
This is the configuration of a personal project hoo.st
As the Zend Framework, you need everything to be redirected to the index.php, as it is used to make friendly url
HTTP ["host"] = ~ "(^|\.)Hoo.st" { server.document-root = "/home/hoo/public_html/demo/public" server.errorlog = "/var/log/lighttpd/websites/hoo_error.log" accesslog.filename = "/var/log/lighttpd/websites/hoo_access.log" setenv.add-environment = ( "APPLICATION_ENV" => "development", "ZF2_PATH" => "/home/hoo/public_html/zf/library" ) url.rewrite-once = ( ".*\(.*)$" => "/index.php? $ 1" ".*\(js|ico|gif|jpg|png|css|html).$" => "$0", "" => "/index.php" ) }
The part that really matters is to set the folder with server.document-root , if it is not in default, and the part of url.rewrite-once
First things first. Explaining the url.rewrite-once:
On the line below, it redirects everything we been through GET to index.php like GET
. "*\(.*)$" => "/index.php?$1"
In this he avoids the redirect of static files, all directed to the actual file.
"*\(js|ico|gif|jpg|png|css|html).. $" => "$0"
Here, everything is called will be redirected to index.php
"" => "/index.php"
considerations
For those who do not know should know!
- lighttpd – http://www.lighttpd.net/ A nice web server
- Zend Framework 2 – http://framework.zend.com/ One of the best frameworks, completely full
- ubuntu – http://www.ubuntu.com/ In my opnion, the best operating system, especially for those who need agility
!
!
.
Leave a Comment