Guest User

Untitled

a guest
Jun 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. = lucid install nginx+php =
  2.  
  3. == install php modules ==
  4. sudo aptitude install php5-cgi php5-cli php5-common php5-curl php5-gd \
  5. php5-imagick php5-json php5-mcrypt php5-mysql php5-pgsql php5-sqlite \
  6. php5-xmlrpc php5-xsl php5-xdebug php-apc php5-memcache memcached
  7.  
  8.  
  9. == install spawn fcgi ==
  10. sudo aptitude install spawn-fcgi
  11.  
  12.  
  13. == config ==
  14. === add init script to /etc/init.d/php5-cgi ===
  15. #! /bin/sh
  16.  
  17. ### BEGIN INIT INFO
  18. # Provides: php5-cgi
  19. # Required-Start: $local_fs $remote_fs $network $syslog
  20. # Required-Stop: $local_fs $remote_fs $network $syslog
  21. # Default-Start: 2 3 4 5
  22. # Default-Stop: 0 1 6
  23. # Short-Description: spawns the php5-cgi
  24. # Description: spawns the php5-cgi
  25. ### END INIT INFO
  26.  
  27. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  28. NAME=php5-cgi
  29. DESC=php5-cgi
  30.  
  31. test -x $DAEMON || exit 0
  32.  
  33. PIDFILE="/var/run/$NAME.pid"
  34. DAEMON="/usr/bin/php5-cgi"
  35. SPAWN_FCGI="/usr/bin/spawn-fcgi"
  36. FCGI_PORT=9000
  37. FCGI_USER="www-data"
  38. FCGI_GROUP="www-data"
  39. FCGI_CHILDREN=10
  40.  
  41. SPAWN_FCGI_OPTS="-f $DAEMON -a 127.0.0.1 -p $FCGI_PORT -u $FCGI_USER -g $FCGI_GROUP -C $FCGI_CHILDREN -P $PIDFILE"
  42.  
  43. set -e
  44.  
  45. . /lib/lsb/init-functions
  46.  
  47. case "$1" in
  48. start)
  49. echo -n "Starting $DESC: "
  50. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
  51. echo "$NAME."
  52. ;;
  53. stop)
  54. echo -n "Stopping $DESC: "
  55. start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
  56. echo "$NAME."
  57. ;;
  58. restart)
  59. echo -n "Restarting $DESC: "
  60. start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
  61. sleep 1
  62. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
  63. echo "$NAME."
  64. ;;
  65. status)
  66. status_of_proc -p $PIDFILE "$DAEMON" php5-cgi && exit 0 || exit $?
  67. ;;
  68. *)
  69. echo "Usage: $NAME {start|stop|restart|status}" >&2
  70. exit 1
  71. ;;
  72. esac
  73.  
  74. exit 0
  75.  
  76.  
  77. === allow to execute ===
  78. sudo chmod +x /etc/init.d/php-cgi
  79.  
  80. == nginx ==
  81. === install ===
  82. sudo aptitude install nginx
  83.  
  84.  
  85. === config ===
  86. server {
  87. listen 80;
  88. server_name dev.*;
  89. root /var/www/$host/web;
  90.  
  91. access_log /var/log/nginx/$host.access.log;
  92. error_log /var/log/nginx/error.log error;
  93.  
  94. location / {
  95. root /var/www/$host/web;
  96. index index.php;
  97.  
  98. # serve static files directly
  99. if (-f $request_filename) {
  100. access_log off;
  101. expires 30d;
  102. break;
  103. }
  104.  
  105. rewrite ^(.*) /index.php last;
  106. }
  107.  
  108. location ~ \.php {
  109. fastcgi_index index.php;
  110.  
  111. set $script $uri;
  112. set $path_info "";
  113. if ($uri ~ "^(.+\.php)(/.*)") {
  114. set $script $1;
  115. set $path_info $2;
  116. }
  117. fastcgi_pass 127.0.0.1:9000;
  118. include /etc/nginx/fastcgi_params;
  119. fastcgi_param SCRIPT_FILENAME /var/www/$host/web$script;
  120. fastcgi_param PATH_INFO $path_info;
  121. fastcgi_param SCRIPT_NAME $script;
  122. }
  123.  
  124. location ~ /\.ht {
  125. deny all;
  126. }
  127. }
  128.  
  129.  
  130. == make it available for nginx ==
  131. sudo ln -s /etc/nginx/sites-available/dev.conf /etc/nginx/sites-enabled/dev.conf
  132.  
  133.  
  134. sudo service php-cgi start
  135. sudo service nginx start
Add Comment
Please, Sign In to add comment