最新帖子 精华区 社区服务 会员列表 统计排行 银行 广告管理
主题 : CentOS上yum安装nginx+mysql+php+php-fastcgi
jack 离线
级别: 管理员
显示用户信息 
0  发表于: 2009-09-11 11:06

CentOS上yum安装nginx+mysql+php+php-fastcgi

首页 » Web服务器 » CentOS上yum安装nginx+mysql+php+php-fastcgi      CentOS上yum安装nginx+mysql+php+php-fastcgi
作者: 键盘人生 | 发布时间: 星期天, 08/09/2009 - 19:17 一、更改yum源为网易的源加快速度
vi /etc/yum.repos.d/CentOS-Base.repo
更改内容如下
    # CentOS-Base.repo
  1. #
  2. # This file uses a new mirrorlist system developed by Lance Davis for CentOS.
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-$releasever - Base
  14. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  15. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
  16. baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
  17. gpgcheck=1
  18. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  19. #released updates
  20. [updates]
  21. name=CentOS-$releasever - Updates
  22. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  23. #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
  24. baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
  25. gpgcheck=1
  26. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  27. #packages used/produced in the build but not released
  28. [addons]
  29. name=CentOS-$releasever - Addons
  30. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
  31. #baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
  32. baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
  33. gpgcheck=1
  34. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  35. #additional packages that may be useful
  36. [extras]
  37. name=CentOS-$releasever - Extras
  38. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  39. #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
  40. baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
  41. gpgcheck=1
  42. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  43. #additional packages that extend functionality of existing packages
  44. [centosplus]
  45. name=CentOS-$releasever - Plus
  46. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  47. #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
  48. baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
  49. gpgcheck=1
  50. enabled=0
  51. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
二、update yum
    yum -y update
三、利用CentOS Linux系统自带的yum命令安装、升级所需的程序库
    LANG=C
  1. yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpnglibpng-devel freetype freetype-devel libxml2 libxml2-devel zlibzlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-develncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5krb5-devel libidn libidn-devel openssl openssl-devel openldapopenldap-devel nss_ldap openldap-clients openldap-servers
四、安装php和mysql
    yum -y install php mysql mysql-server mysql-devel php-mysql php-cgi php-mbstring php-gd php-fastcgi
五、安装nginx
由于centos没有默认的nginx软件包,需要启用REHL的附件包
    rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
  1. yum -y install nginx
设置开机启动
    chkconfig nginx on
六、安装spawn-fcgi来运行php-cgi

    yum install spawn-fcgi
七、下载spawn-fcgi 的启动脚本
    wget http://bash.cyberciti.biz/dl/419.sh.zip
  1. unzip 419.sh.zip
  2. mv 419.sh /etc/init.d/php_cgi
  3. chmod +x /etc/init.d/php_cgi
启动php_cgi
    /etc/init.d/php_cgi start
查看进程
    netstat -tulpn | grep :9000
若出现如下代表一切正常
    tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4352/php-cgi
八、配置nginx(详细配置见nginx.conf详细说明)
    location ~ \.php$ {
  1. root html;
  2. fastcgi_pass 127.0.0.1:9000;
  3. fastcgi_index index.php;
  4. fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
  5. include fastcgi_params;
  6. }
九、查看phpinfo
编写脚本
    phpinfo();
十、安装phpmyadmin
修改/var/lib/php/session的权限和nginx和php_cgi一致
    chown -R www.www /var/lib/php/session

http://www.clittle.cn/2009/08/centos-nginx-php-fastcgi-mysql.html
From:局域网 顶端
快速回复 顶端
内容
HTML 代码不可用
使用签名
Wind Code自动转换

按"Ctrl+Enter"直接提交