nginxã§php5ãå©ç¨ããæ¹æ³ã§ããapache2ããããããä¹ãæãã¾ããã
fastcgiãä¸çªãããããã£ãã®ã§ã¡ã¢ãã¦ããã¾ããä¸è¨ç°å¢ã¯debian5ã§ãã
ç°å¢ã¯ãããVPSä¸ã®debianã§ãã
ï¼ï¼nginx, php5é¢ä¿ã®ã¤ã³ã¹ãã¼ã«
# apt-get update # apt-get upgrade # apt-get install nginx php5-cli php5-cgi php5-gd spawn-fcgi
debian5ã§ã¯spawn-fcgiã¯aptããå
¥ãããã¾ããã
http://redmine.lighttpd.net/projects/spawn-fcgi
ããã½ã¼ã¹ããspawn-fcgiãã¤ã³ã¹ãã¼ã«ãã¦ãã ããã
# wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz # tar zxvf spawn-fcgi-1.6.3.tar.gz # cd spawn-fcgi-1.6.3 # ./configure # make # make install
ï¼ï¼php-fastcgiã®ä½æã¨ç·¨é(spawn-fcgiã®wrapper)
# vim /usr/bin/php-fastcgi
#! /bin/sh /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 6 -u www-data -f /usr/bin/php5-cgi # /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 6 -u www-data -f /usr/bin/php5-cgi
# chmod 755 /usr/bin/php-fastcgi
ã½ã¼ã¹ããspawn-fcgiãå
¥ããå ´åã®ãã¹ã¯/usr/local/bin/spawn-fcgiã«ãªãã¾ãã
ã¾ãphp5-cgiãåå¨ããªãã¨ãã¨ã©ã¼ã¯åºã¾ããã®ã§æ³¨æãã¦ãã ããã
ï¼ï¼/etc/init.d/php-fastcgiãä½æ
ï¼ã§è¨å®ããããã«fastcgiã¯ãã¼ã¢ã³ã¨ãã¦é§å¨ãã¾ããfastcgiãèµ·åã¹ã¯ãªããã
/etc/init.d/ 以ä¸ã« ãä½æ
# vim /etc/init.d/php-fastcgi
#!/bin/bash ### BEGIN INIT INFO # Provides: php-fastcgi # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the php-fastcgi # Description: starts the php-fastcgi ### END INIT INFO PHP_SCRIPT=/usr/bin/php-fastcgi FASTCGI_USER=www-data RETVAL=0 PIDFILE=/var/run/php5-cgi.pid case "$1" in start) su - $FASTCGI_USER -c $PHP_SCRIPT pidof php5-cgi > $PIDFILE RETVAL=$? ;; stop) killall -9 php5-cgi echo '' > $PIDFILE RETVAL=$? ;; restart) killall -9 php5-cgi su - $FASTCGI_USER -c $PHP_SCRIPT pidof php5-cgi > $PIDFILE RETVAL=$? ;; *) echo "Usage: php-fastcgi {start|stop|restart}" exit 1 ;; esac exit $RETVAL console output
# chmod 755 /etc/init.d/php-fastcgi # update-rc.d php-fastcgi defaults # /etc/init.d/php-fastcgi start
èµ·åããã¨
spawn-fcgi: child spawned successfully: PID: 0000
ã¨ããã¡ãã»ã¼ã¸ãåºã¾ãã
2142 ? Ss 0:00 /usr/bin/php5-cgi 2143 ? S 0:00 /usr/bin/php5-cgi 2144 ? S 0:00 /usr/bin/php5-cgi 2145 ? S 0:00 /usr/bin/php5-cgi 2146 ? S 0:00 /usr/bin/php5-cgi 2147 ? S 0:00 /usr/bin/php5-cgi 2148 ? S 0:00 /usr/bin/php5-cgi
ãã¼ã¢ã³ã¨ãã¦php5-cgiãé§å¨ãã¾ãã
ï¼ï¼nginxã®è¨å®
# mkdir /var/www/yourhostname.com # chown -R www-data:www-data /var/www/yourhostname.com # vim /etc/nginx/nginx.conf
nginx.confã®å 容
user www-data; worker_processes 1; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; sendfile on; keepalive_timeout 65; tcp_nodelay on; gzip on; server { listen 80; server_name yourhostname.com; access_log /var/log/nginx/yourhostname.com.log; error_log /var/log/nginx/yourhostname.com.error.log; location / { root /var/www/yourhostname.com; index index.html index.htm index.php mtview.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/yourhostname.com$fastcgi_script_name; } } }
è¨å®ãã¡ã¤ã«ã®èª¬æã¯ããã»ã©å¿
è¦ã§ã¯ãªãã¨æãã¾ãã
Apacheã§ããDirectoryIndexesãindexé
ç®ã«ãªããDocumentRootãrooté
ç®ã«ã
ããã§ã¯ãã³ãã¬ã¼ãã ããè¼ãã¦ããã¾ãã詳細ã¯æ¤ç´¢ãã¦ãã ããã
ç§ãå®é¨ããç°å¢ã§ã¯èªåã§èµ·åããªãããã«ãªã£ã¦ãã¾ããã®ã§
# update-rc.d nginx defaults
nginxã®èµ·å
# /etc/init.d/nginx start # nginxã®èµ·å
2130 ? Ss 0:00 nginx: master process /usr/sbin/nginx 2131 ? S 0:00 nginx: worker process
ã¨ãã¦nginxãé§å¨ãã¾ãã
nginxã®è¨å®ãã¡ã¤ã«ã®ãªãã¼ããæ§æãã§ãã¯ã¯ä¸è¨ã®ã¨ããã§ãã
ãªãã¼ãï¼nginx -t æ§æãã§ãã¯ï¼nginx -s reload
ãã¨ã¯/var/www/yourdomain.comã«index.phpãªã©ã§phpãåããã ãã§ãã
ã¨ã©ã¼ãåºãã¨ãã«
ãNo input file specified.ãã®ã¨ã©ã¼
fastcgi_param SCRIPT_FILENAME /var/www/yourhostname.com$fastcgi_script_name; ã®ãã¹ãééã£ã¦ããå ´åãphp cgiã®å ´æãä¸æã®ã¨ã©ã¼ã
åèï¼
http://library.linode.com/web-servers/nginx/php-fastcgi/ubuntu-10.04-lucid
http://wiki.nginx.org/FcgiExampleJa
http://hima-j.in/linux/sakura-vps-ubuntu-10-04-nginx-php-fastcgi-web-server/
http://wiki.nginx.org/Configuration