Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- = lucid install nginx+php =
- == install php modules ==
- sudo aptitude install php5-cgi php5-cli php5-common php5-curl php5-gd \
- php5-imagick php5-json php5-mcrypt php5-mysql php5-pgsql php5-sqlite \
- php5-xmlrpc php5-xsl php5-xdebug php-apc php5-memcache memcached
- == install spawn fcgi ==
- sudo aptitude install spawn-fcgi
- == config ==
- === add init script to /etc/init.d/php5-cgi ===
- #! /bin/sh
- ### BEGIN INIT INFO
- # Provides: php5-cgi
- # 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: spawns the php5-cgi
- # Description: spawns the php5-cgi
- ### END INIT INFO
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
- NAME=php5-cgi
- DESC=php5-cgi
- test -x $DAEMON || exit 0
- PIDFILE="/var/run/$NAME.pid"
- DAEMON="/usr/bin/php5-cgi"
- SPAWN_FCGI="/usr/bin/spawn-fcgi"
- FCGI_PORT=9000
- FCGI_USER="www-data"
- FCGI_GROUP="www-data"
- FCGI_CHILDREN=10
- SPAWN_FCGI_OPTS="-f $DAEMON -a 127.0.0.1 -p $FCGI_PORT -u $FCGI_USER -g $FCGI_GROUP -C $FCGI_CHILDREN -P $PIDFILE"
- set -e
- . /lib/lsb/init-functions
- case "$1" in
- start)
- echo -n "Starting $DESC: "
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
- echo "$NAME."
- ;;
- stop)
- echo -n "Stopping $DESC: "
- start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
- echo "$NAME."
- ;;
- restart)
- echo -n "Restarting $DESC: "
- start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
- sleep 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
- echo "$NAME."
- ;;
- status)
- status_of_proc -p $PIDFILE "$DAEMON" php5-cgi && exit 0 || exit $?
- ;;
- *)
- echo "Usage: $NAME {start|stop|restart|status}" >&2
- exit 1
- ;;
- esac
- exit 0
- === allow to execute ===
- sudo chmod +x /etc/init.d/php-cgi
- == nginx ==
- === install ===
- sudo aptitude install nginx
- === config ===
- server {
- listen 80;
- server_name dev.*;
- root /var/www/$host/web;
- access_log /var/log/nginx/$host.access.log;
- error_log /var/log/nginx/error.log error;
- location / {
- root /var/www/$host/web;
- index index.php;
- # serve static files directly
- if (-f $request_filename) {
- access_log off;
- expires 30d;
- break;
- }
- rewrite ^(.*) /index.php last;
- }
- location ~ \.php {
- fastcgi_index index.php;
- set $script $uri;
- set $path_info "";
- if ($uri ~ "^(.+\.php)(/.*)") {
- set $script $1;
- set $path_info $2;
- }
- fastcgi_pass 127.0.0.1:9000;
- include /etc/nginx/fastcgi_params;
- fastcgi_param SCRIPT_FILENAME /var/www/$host/web$script;
- fastcgi_param PATH_INFO $path_info;
- fastcgi_param SCRIPT_NAME $script;
- }
- location ~ /\.ht {
- deny all;
- }
- }
- == make it available for nginx ==
- sudo ln -s /etc/nginx/sites-available/dev.conf /etc/nginx/sites-enabled/dev.conf
- sudo service php-cgi start
- sudo service nginx start
Add Comment
Please, Sign In to add comment