Ubuntu 9.04 server安装nginx+php(fastcgi)
来源:互联网 发布:变量被优化 编辑:程序博客网 时间:2024/05/10 21:27
准备知识:
Ubuntu :
Ubuntu 是linux的一个版本,有非洲发布的,现在比较流行的一个版本。
参考百度说明Ubuntu
nginx :
Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两年半了。Igor 将源代码以类BSD许可证的形式发布。尽管还是测试版,但是,Nginx 已经因为它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名了。
Nginx 的中文维基:http://wiki.codemongers.com/NginxChs
Nginx 的中文站: http://www.nginx.cn
参考 百度百科解释NGINX
FastCGI:
个人初步感觉是CGI的先进产物,据说速度比CGI快五倍。
好了,现在来安装:
第一步,安装nginx
由于Ubuntu 904已经包含了nginx,所以根本不要编译,安装超简单!
修改/etc/apt/sources.list文件内容为国内镜像,然后运行:
apt-get update
apt-get install nginx
即可完成安装
启动nginx:
/etc/init.d/nginx start
然后就可以访问了,http://localhost/ , 一切正常!如果不能访问,先不要继续,看看是什么原因,解决之后再继续。
下面配置php 和mysql。
第二步,安装Php和mysql
安装php和MySQL:
apt-get install php5-cli php5-cgi mysql-server-5.1 php5-mysql
第三步,安装FastCgi和配置
我们需要/usr/bin/spawn-fcgi这个文件,而它是属于lighttpd这个包里面的,所以我们安装lighttpd然后把它设置为开机不启动:
apt-get install lighttpd #我们只要/usr/bin/spawn-fcgi
rcconf #去掉lighttpd开机自启动
修改nginx的配置文件:/etc/nginx/sites-available/default
修改 server_name 58.30.17.154;
修改index的一行修改为:
index index.php index.html index.htm;
去掉下面部分的注释:
location ~ /.php$ {
fastcgi _pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/nginx-default $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
特别注意上面红色的字。
重新启动nginx:
/etc/init.d/nginx stop
/etc/init.d/nginx start
启动fastcgi php:
spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi
为了让php-cgi开机自启动:
cd /etc/init.d
cp nginx php-cgi
打开修改/etc/init.d/nginx文件
sudo gedit /etc/init.d/nginx
添加或修改相应位置:
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid /
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid /
--exec $DAEMON
echo "$NAME."
pkill -9 php-cgi
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile /
/var/run/$NAME.pid --exec $DAEMON
pkill -9 php-cgi
sleep 1
start-stop-daemon --start --quiet --pidfile /
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi
;;
保存后测试一下
sudo /etc/init.d/nginx start
然后浏览器访问http://localhost/
在/var/www/nginx-default/目录下创建一个文件: /var/www/nginx-default/index.php
文件内容是:
< ?php phpinfo();?>
然后浏览器访问nginx就可以看到一切正常了
- Ubuntu 9.04 server安装nginx+php(fastcgi)
- Ubuntu下安装Nginx+PHP+MySQL+FastCGI
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- nginx+PHP+PHP-FPM(FastCGI)在Ubuntu上的安装和配置
- centos yum安装 nginx +php+fastcgi
- nginx+php(fastcgi)安装教程
- 在Ubuntu 8.04 LTS(hardy)下安装配置nginx和fastcgi方式的php
- ubuntu server安装nginx
- Nginx+FastCGI+PHP-2
- nginx php fastcgi
- nginx php fastCGI配置
- nginx与php(fastcgi)
- CentOS上yum安装nginx+mysql+php+php-fastcgi
- Ubuntu安装nginx、php
- Ubuntu Server 10.10安装配置Nginx+php-fpm+mysql
- 最简单的java单例
- Linux 下的错误 error.h
- int86相关(Borland C++)
- Nice Menus模块的安装使用
- tomcat发布基于jersey的WebService(二)
- Ubuntu 9.04 server安装nginx+php(fastcgi)
- 无奈
- Flex 各个keycode值对照
- 14.字符串、格式化、正则表达式【下】
- java实现中文转化为拼音与简称
- 清理windows资源管理器右键"打开方式","新建"菜单
- drupal:如何显示primary-link的子菜单
- 努力点
- 基础一:对回调函数的理解