LoginSignup
11
12

More than 5 years have passed since last update.

nginxでPHPを動かす

Posted at

前回virtualbox + ubuntuにnginxをインストールでnginxは起動できたので、
では早速PHPを動かしてみたいと思います。

環境


  • VirtualBox 4.3
  • ubuntu 14.04
  • nginx 1.6.2
  • PHP-fpm 5.5.9

PHP-fpm(FastCGI Process Manager)インストール


$ sudo apt-get install php5-fpm
$ ps aux | grep php-fpm 

nginxの設定


/etc/nginx/conf.d/default.conf

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

※上記コメントアウト行のコメントアウトを削除する
※rootに任意のパスを設定する
※fastcgi_passにphp5-fpmを指定
※fastcgi_paramを上記のように修正

nginx起動


$ sudo /etc/init.d/nginx start

phpinfoを出力してみる


/usr/share/nginx/html/index.php

<?php
phpinfo();

※画面に表示されることを確認

11
12
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
11
12