インストール
- yum 実行
# yum install nginx
設定
- 以下の内容で /etc/nginx/conf.d/phalcon.conf を作成
server {
listen 80;
server_name localhost.dev;
rewrite_log on;
index index.php index.html index.htm;
set $root_path '/var/www/phalcon';
root $root_path;
location / {
try_files $uri $uri/ /index.php;
}
location /tutorial/ {
rewrite ^/tutorial/$ /tutorial/public/ last;
rewrite ^/tutorial/(.*) /tutorial/public/$1 last;
}
location /tutorial/public/ {
try_files $request_filename $request_filename/ @rewrite;
}
location @rewrite {
rewrite ^/tutorial/public/(.*)$ /tutorial/public/index.php?_url=/$1 last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param X_FORWARDED_FOR $proxy_add_x_forwarded_for;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
起動
- 設定確認
# service nginx configtest
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
- サービス起動
# service nginx start
- 自動起動設定
# chkconfig nginx on