VPS: Nginx, PHP5 & ASP.NET with FastCGI on ubuntu-server 10.04 LTS
时间:2010-09-28 来源:Fisher.W
Install Required Packages
# Set mono update sources echo "deb http://badgerports.org lucid main" >> /etc/apt/sources.list # Install Nginx, Mono, PHP5 apt-get update apt-get install nginx mono-fastcgi-server2 php5-cgi php5-cli spawn-fcgi
Configure Sites
File: /etc/nginx/fastcgi_params
Append:
fastcgi_param PATH_INFO ""; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
File: /etc/nginx/sitesites-available/default
server {
listen 80;
server_name dotnet.domain.com;
access_log /var/log/nginx/dotnet.domain.com.access.log;
location / {
root /var/www/dotnet.domain.com;
index index.html index.htm default.aspx Default.aspx;
fastcgi_index Default.aspx;
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/fastcgi_params;
}
}
server {
listen 80;
server_name php.domain.com;
access_log /var/log/nginx/php.domain.com.access.log;
location / {
root /var/www/php.domain.com;
index index.html index.htm;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9001;
include /etc/nginx/fastcgi_params;
}
}
Configure FastCGI
File: /etc/init.d/monoserver
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/mono
NAME=monoserver
DESC=monoserver
MONOSERVER=$(which fastcgi-mono-server2)
MONOSERVER_PID=$(ps auxf | grep fastcgi-mono-server2.exe | grep -v grep | awk '{print $2}')
WEBAPPS="dotnet.domain.com:/:/var/www/dotnet.domain.com/"
case "$1" in
start)
if [ -z "${MONOSERVER_PID}" ]; then
echo "starting mono server"
${MONOSERVER} /applications=${WEBAPPS} /socket=tcp:127.0.0.1:9000 &
echo "mono server started"
else
echo ${WEBAPPS}
echo "mono server is running"
fi
;;
stop)
if [ -n "${MONOSERVER_PID}" ]; then
kill ${MONOSERVER_PID}
echo "mono server stopped"
else
echo "mono server is not running"
fi
;;
esac
exit 0
File: /etc/init.d/php-fastcgi
#!/bin/sh
PHP_SCRIPT=/usr/bin/php-fastcgi
FASTCGI_USER=www-data
RETVAL=0
case "$1" in
start)
su - $FASTCGI_USER -c $PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php5-cgi
RETVAL=$?
;;
restart)
killall -9 php5-cgi
su - $FASTCGI_USER -c $PHP_SCRIPT
RETVAL=$?
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
File: /usr/bin/php-fastcgi
#!/bin/sh /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9001 -C 6 -u www-data -f /usr/bin/php5-cgi
Start Server
Set file access permission:
chmod a+x /usr/bin/php-fastcgi chmod 755 /etc/init.d/monoserver update-rc.d monoserver defaults chmod 755 /etc/init.d/php-fastcgi update-rc.d php-fastcgi defaults
Start service:
/etc/init.d/nginx restart /etc/init.d/monoserver restart /etc/init.d/php-fastcgi restart
More Information
这篇log是事后依靠会议写的,不是当时的笔记,所以可能有不对的地方,还请高手指出。
Change Log
- v1.0(2010-09-28): The first draft.
相关阅读 更多 +
排行榜 更多 +










