6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Nginx

Last updated at Posted at 2014-11-11

インストール

Install

  • 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
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?