Created
April 7, 2014 07:15
-
-
Save amolkhanorkar/10015952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nginx setup | |
Install Required Packages (Pre-requisite php & project required directory should be installed) | |
apt-get update | |
apt-get upgrade | |
apt-get install nginx php5-cli php5-cgi spawn-fcgi | |
Now we will do the fastcgi configuration with nginx. In this we are going to use tcp socket base communication. | |
i. Start fastcgi deamon | |
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/php-cgi.pid -C 6 | |
ii. You can use below script to start fastcgi process | |
#!/bin/bash | |
COMMAND=/usr/bin/spawn-fcgi | |
NAME=php5-cgi | |
ADDRESS=127.0.0.1 | |
PORT=9000 | |
USER=www-data | |
GROUP=www-data | |
PHPCGI=/usr/bin/php5-cgi | |
PIDFILE=/var/run/php5-cgi.pid | |
CHILDREN=6 | |
PHP5=/usr/bin/php5-cgi | |
case "$1" in | |
start) | |
$COMMAND -a $ADDRESS -p $PORT -u $USER -g $GROUP -f $PHPCGI -P /var/run/$NAME.pid -C $CHILDREN | |
echo -n "$NAME started with pid " | |
echo `cat /var/run/$NAME.pid` | |
;; | |
stop) | |
if [ -e /var/run/$NAME.pid ] | |
then | |
killall php5-cgi | |
rm /var/run/$NAME.pid | |
echo "$NAME stopped" | |
else | |
echo "$NAME is not running, no pid file in /var/run/php-fastcgi" | |
fi | |
;; | |
restart) | |
killall php5-cgi | |
rm /var/run/$NAME.pid | |
echo "$NAME stopped" | |
$COMMAND -a $ADDRESS -p $PORT -u $USER -g $GROUP -f $PHPCGI -P /var/run/$NAME.pid -C $CHILDREN | |
echo -n "$NAME started with pid " | |
echo `cat /var/run/$NAME.pid` | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
exit $RETVAL | |
Create Virtualhost in nginx | |
vim /etc/nginx/sites-available/example | |
server { | |
listen 80; | |
server_name crpt.crucibleapp.com; | |
root /var/www/; | |
index index.php index.html index.htm; | |
location ~ \.php$ { | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$ | |
fastcgi_script_name;include fastcgi_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment