RHEL5+nginx+fastcgi+php实现lnmp环境
2013-06-17 18:48
399 查看
RHEL5+nginx+fastcgi+php实现lnmp环境
准备
kill本机的80端口
nginx-1.5.1.tar.gz安装包 www.wiki.nginx.org
php运行管理脚本
##
#!/bin/sh
#
# php-cgi - php-fastcgi swaping via spawn-fcgi
#
# chkconfig: - 85 15
# description: Run php-cgi as appserver
# processname: php-cgi
# config: /etc/sysconfig/phpfastcgi(defaults RH style)
# pidfile: /var/run/php_cgi.pid
# Note: See how to use this script :
# http://www.cyberciti.biz/faq/rhel-fedora-install-configure-nginx-php5/ # Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
spawnfcgi="/usr/bin/spawn-fcgi"
php_cgi="/usr/bin/php-cgi"
prog=$(basename $php_cgi)
server_ip=127.0.0.1
server_port=9000
server_user=nginx
server_group=nginx
server_childs=5
pidfile="/var/run/php_cgi.pid"
# do not edit, put changes in /etc/sysconfig/phpfastcgi
[ -f /etc/sysconfig/phpfastcgi ] && . /etc/sysconfig/phpfastcgi
start() {
[ -x $php_cgi ] || exit 1
[ -x $spawnfcgi ] || exit 2
echo -n $"Starting $prog:"
daemon $spawnfcgi -a ${server_ip} -p${server_port} -u ${server_user} -g ${server_group} -P ${pidfile} -C${server_childs} -f ${php_cgi}
retval=$?
echo
return $retval
}
stop() {
echo -n $"Stopping $prog:"
killproc -p ${pidfile} $prog-QUIT
retval=$?
echo
[ -f ${pidfile} ] && /bin/rm-f ${pidfile}
return $retval
}
restart(){
stop
sleep 2
start
}
rh_status(){
status -p ${pidfile} $prog
}
case "$1" in
start)
start;;
stop)
stop;;
restart)
restart;;
status)
rh_status;;
*)
echo $"Usage: $0{start|stop|restart|status}"
exit 3
esac
1,源码安装nginx
tar fzvx nginx-1.5.1.tar.gz -C /usr/src
./configure --prefix=/usr/local/nginx
make
make install
2,启动nginx 测试
/usr/local/nginx/sbin/nginx
lsof -i :80
echo 'nginx welcome' > html/index.htm
http://localhost
3, 利用yum安装php,mysql
yum install php php-mysql php-pdo php-cli mysql mysql-server
4,下载spawn-fcgi-1.6.3-1.el5.i386.rpm 工具包并安装
**使php模块作为本机内存运行的服务**
rpm -ivh spawn-fcgi-1.6.3-1.el5.i386.rpm
5,下载运行php服务的管理脚本放在/etc/init.d/php下以便能用service命令启用
cp php_cgi /etc/init.d/php
chmod +x /etc/init.d/php
useradd nginx
service php start
lsof -i :9000
6,添加php网页phpinfo.php测试页面在/usr/local/nginx/html下
<?php phpinfo(); ?>
7,修改nginx主配文件
Vim /uar/local/nginx/conf/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include
fastcgi_params; }
8,测试在浏览器中运行php网页phpinfo.php http://localhost/phpinfo.php。
准备
kill本机的80端口
nginx-1.5.1.tar.gz安装包 www.wiki.nginx.org
php运行管理脚本
##
#!/bin/sh
#
# php-cgi - php-fastcgi swaping via spawn-fcgi
#
# chkconfig: - 85 15
# description: Run php-cgi as appserver
# processname: php-cgi
# config: /etc/sysconfig/phpfastcgi(defaults RH style)
# pidfile: /var/run/php_cgi.pid
# Note: See how to use this script :
# http://www.cyberciti.biz/faq/rhel-fedora-install-configure-nginx-php5/ # Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
spawnfcgi="/usr/bin/spawn-fcgi"
php_cgi="/usr/bin/php-cgi"
prog=$(basename $php_cgi)
server_ip=127.0.0.1
server_port=9000
server_user=nginx
server_group=nginx
server_childs=5
pidfile="/var/run/php_cgi.pid"
# do not edit, put changes in /etc/sysconfig/phpfastcgi
[ -f /etc/sysconfig/phpfastcgi ] && . /etc/sysconfig/phpfastcgi
start() {
[ -x $php_cgi ] || exit 1
[ -x $spawnfcgi ] || exit 2
echo -n $"Starting $prog:"
daemon $spawnfcgi -a ${server_ip} -p${server_port} -u ${server_user} -g ${server_group} -P ${pidfile} -C${server_childs} -f ${php_cgi}
retval=$?
echo
return $retval
}
stop() {
echo -n $"Stopping $prog:"
killproc -p ${pidfile} $prog-QUIT
retval=$?
echo
[ -f ${pidfile} ] && /bin/rm-f ${pidfile}
return $retval
}
restart(){
stop
sleep 2
start
}
rh_status(){
status -p ${pidfile} $prog
}
case "$1" in
start)
start;;
stop)
stop;;
restart)
restart;;
status)
rh_status;;
*)
echo $"Usage: $0{start|stop|restart|status}"
exit 3
esac
1,源码安装nginx
tar fzvx nginx-1.5.1.tar.gz -C /usr/src
./configure --prefix=/usr/local/nginx
make
make install
2,启动nginx 测试
/usr/local/nginx/sbin/nginx
lsof -i :80
echo 'nginx welcome' > html/index.htm
http://localhost
3, 利用yum安装php,mysql
yum install php php-mysql php-pdo php-cli mysql mysql-server
4,下载spawn-fcgi-1.6.3-1.el5.i386.rpm 工具包并安装
**使php模块作为本机内存运行的服务**
rpm -ivh spawn-fcgi-1.6.3-1.el5.i386.rpm
5,下载运行php服务的管理脚本放在/etc/init.d/php下以便能用service命令启用
cp php_cgi /etc/init.d/php
chmod +x /etc/init.d/php
useradd nginx
service php start
lsof -i :9000
6,添加php网页phpinfo.php测试页面在/usr/local/nginx/html下
<?php phpinfo(); ?>
7,修改nginx主配文件
Vim /uar/local/nginx/conf/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; include
fastcgi_params; }
8,测试在浏览器中运行php网页phpinfo.php http://localhost/phpinfo.php。
相关文章推荐
- LNMP基于FastCGI实现Nginx,PHP,MySQL的架构分离
- LNMP基于fastcgi实现nginx,php,mysql的分离安装部署
- CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装wordpress
- LNMP基于fastcgi实现nginx,php,mysql的分离
- CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress
- LNMP基于fastcgi实现nginx,php,mysql的分离
- LNMP搭建,nginx整合php-fpm即fastCGI实现,以及nginx的多虚拟主机配置
- Rhel6.5_Nginx1.45_Php5.59_MySQL5.6.16编译安装(集成LNMP环境)
- LNMP基于fastcgi实现nginx,php,mysql的分离
- LNMP基于fastcgi实现nginx,php,mysql的分离
- CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress、Discuz
- CentOS下安装LNMP(LINUX+NGINX+MYSQL+PHP)环境
- centos6.5下使用yum完美搭建LNMP环境(php5.6,mysql5.5,nginx1.10)
- linux后台服务器开发环境部署配置和验证(nginx+apache+php-fpm+FASTCGI(C/C++))
- LNMP(linux+nginx+mysql+php)环境搭建_1
- Docker部署WordPress LNMP(Nginx PHP MySQL)环境实践
- centos安装lnmp环境(nginx+mysql+php)
- Nginx安装配置PHP(FastCGI)环境的教程
- RHEL5.4 安装nginx-1.0 + php-5.2.17(fastcgi)+mysql-5.1.40 推荐
- LNMP(linux+nginx+mysql+php)服务器环境配置