Hi All!
how to configure lighttpd web server to work with phalcon? wich rules must be written in config file?
thanks!
|
Jan '14 |
7 |
2206 |
3 |
Hi All!
how to configure lighttpd web server to work with phalcon? wich rules must be written in config file?
thanks!
I think, you talk about Apache... In Lighttpd there not are directives "Options" and "directory"
my temporary solve is:
url.rewrite-once = (
"^/(js|img|css|bootstrap)(/.*)$" => "/$1$2",
"^/(.*)\?(.*)$" => "/index.php?_url=/$1/$2",
"^/(.*)$" => "/index.php?_url=/$1"
)
Remove # for paginator "^/(.)\?(.)$" => "/index.php?_url=/$1/$2",
Because you will have problems with url like /controller/action Just add "^/(.*)$" => "/index.php?_url=/$1" Everything else you need to setup in Router You have nice tutorial at link below https://docs.phalcon.io/en/latest/reference/routing.html
PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
LANG en_US.UTF-8
LC_MESSAGES C
PHP_FCGI_CHILDREN 4
PHP_FCGI_MAX_REQUESTS 1000
HTTP_ACCEPT_LANGUAGE en-US,en;q=0.8
HTTP_ACCEPT_ENCODING gzip,deflate,sdch
HTTP_DNT 1
HTTP_USER_AGENT Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_CONNECTION keep-alive
HTTP_HOST varch.dev
SERVER_PROTOCOL HTTP/1.1
REDIRECT_STATUS 200
REQUEST_METHOD GET
QUERY_STRING _url=/
REDIRECT_URI /index.php?_url=/
REQUEST_URI /
DOCUMENT_ROOT /home/oleg/www/public
SCRIPT_FILENAME /home/oleg/www/public/index.php
PATH_INFO
SCRIPT_NAME /index.php
REMOTE_ADDR 172.16.0.1
REMOTE_PORT 52035
SERVER_ADDR 172.16.0.4
SERVER_PORT 80
GATEWAY_INTERFACE CGI/1.1
SERVER_NAME varch.dev
SERVER_SOFTWARE lighttpd/1.4.33
FCGI_ROLE RESPONDER
PHP_SELF /index.php
REQUEST_TIME_FLOAT 1389720003.0483
REQUEST_TIME 1389720003
lighttpd.conf
# This is a minimal example config
# See /usr/share/doc/lighttpd
# and https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions
server.modules = (
"mod_rewrite",
"mod_redirect",
# "mod_alias",
# "mod_auth",
# "mod_status",
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
# "mod_cgi",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_webdav"
)
server.port = 80
server.username = "http"
server.groupname = "http"
#server.document-root = "/srv/http"
server.document-root = "/home/oleg/www/public"
server.errorlog = "/var/log/lighttpd/error.log"
server.max-keep-alive-requests = 4
server.max-keep-alive-idle = 4
server.max-fds = 2048
server.event-handler = "linux-sysepoll"
server.stat-cache-engine = "simple"
dir-listing.activate = "enable"
index-file.names = ( "index.php, index.html" )
url.rewrite-once = (
"^/([^.?]*)\?(.*)$" => "/index.php?_url=/$1",
"^/([^.?]*)$" => "/index.php?_url=/$1",
)
include "conf.d/mimetype.conf"
include "conf.d/fastcgi.conf"
conf.d/fastcgi.conf
#######################################################################
##
## FastCGI Module
## ---------------
##
## https://www.lighttpd.net/documentation/fastcgi.html
##
server.modules += ( "mod_fastcgi" )
##
## PHP Example
## For PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini.
##
## The number of php processes you will get can be easily calculated:
##
## num-procs = max-procs * ( 1 + PHP_FCGI_CHILDREN )
##
## for the php-num-procs example it means you will get 17*5 = 85 php
## processes. you always should need this high number for your very
## busy sites. And if you have a lot of RAM. :)
##
#fastcgi.server = ( ".php" =>
# ( "php-local" =>
# (
# "socket" => socket_dir + "/php-fastcgi-1.socket",
# "bin-path" => server_root + "/cgi-bin/php5",
# "max-procs" => 1,
# "broken-scriptfilename" => "enable",
# )
# ),
# ( "php-tcp" =>
# (
# "host" => "127.0.0.1",
# "port" => 9999,
# "check-local" => "disable",
# "broken-scriptfilename" => "enable",
# )
# ),
#
# ( "php-num-procs" =>
# (
# "socket" => socket_dir + "/php-fastcgi-2.socket",
# "bin-path" => server_root + "/cgi-bin/php5",
# "bin-environment" => (
# "PHP_FCGI_CHILDREN" => "16",
# "PHP_FCGI_MAX_REQUESTS" => "10000",
# ),
# "max-procs" => 5,
# "broken-scriptfilename" => "enable",
# )
# ),
# )
## chrooted webserver + external PHP
##
## $ spawn-fcgi -f /usr/bin/php-cgi -p 2000 -a 127.0.0.1 -C 8
##
## webserver chrooted to /srv/www/
## php running outside the chroot
#
#fastcgi.server = (
# ".php" => ((
# "host" => "127.0.0.1",
# "port" => "2000",
# "docroot" => "/srv/www/servers/www.example.org/htdocs/"
# )))
#
#server.chroot = "/srv/www"
#server.document-root = "/servers/wwww.example.org/htdocs/"
#
##
#######################################################################
#server.indexfiles += ( "index.php" ) #this is deprecated
index-file.names += ( "index.php" )
fastcgi.server = (
".php" => (
"localhost" => (
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php-fastcgi.sock",
# "host" => "127.0.0.1",
# "port" => "9000",
"max-procs" => 10, # default value
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4", # default value
"PHP_FCGI_MAX_REQUESTS" => "1000",
),
"nax-load-per-proc" => 1000,
"idle-timeout" => 3,
"broken-scriptfilename" => "enable"
))
)
conf.d/mimetype.conf
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".weba" => "audio/weba",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".svg" => "image/svg+xml",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml; charset=utf-8",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".ogv" => "video/ogg",
".webm" => "video/webm",
".mov" => "video/quicktime",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar",
"" => "application/octet-stream",
)
There is nothing easier :) Time of respond - 9 ms on FastCGI request Convenient than Apache, is not it?
Server root directory is any folder, which have index.php of Phalcon application. That is, the server task - start index.php of your project. After the request is processed by PHP (your Phalcon application). Server pull response of your application and send it to client. If your application is within server directory example.com, like folder_of_example_com/subfolder, you can use vhost. In any case, you server (vhost) root folder should point to the any_path_for_php_application, which contain your bootstrap file (index.php).