Zend Framework with Nginx (Directory Alias) Notice: If you didn't know how to run PHP within Nginx, just follow my previous article: PHP5 with Nginx + FastCGI. ZF installation: $ su Password: # cd /to/your/download/path/ # unzip -q ZendFramework-1.9.1-minimal.zip -d /usr/local/ # mv /usr/local/ZendFramework-1.9.1-minimal /usr/local/zendframework # ln -s /usr/local/zendframework/bin/zf.sh /usr/local/bin/zf # zf show version Zend Framework Version: 1.9.1 Creating new ZF project: $ cd /to/your/project/path/ $ zf create project belajar-zf Creating project at /your/project/path/belajar-zf $ ln -s /usr/local/zendframework/library/Zend /your/project/path/belajar-zf/library/ Configuring Nginx: # vim /etc/nginx/sites-available/default ... server { listen 82; server_name localhost; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { root /var/www; index index.html index.php; } location ~ ^/belajar-zf/(.*\.php)$ { alias /your/project/path/belajar-zf/public/$1; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 256k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on;
Page 1 of 2
include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; } location /belajar-zf/ { alias /your/project/path/belajar-zf/public/; index index.php; if (!-e $request_filename) { rewrite ^/(.*)$ /belajar-zf/index.php last; break; } } ... } :wq # /etc/init.d/nginx restart Restarting nginx: nginx. Test with browser: http://localhost:82/belajar-zf/
Page 2 of 2