Chinaunix首页 | 论坛 | 博客
  • 博客访问: 119384
  • 博文数量: 27
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 280
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-15 19:04
文章分类

全部博文(27)

文章存档

2015年(1)

2014年(26)

分类: 系统运维

2014-04-06 19:18:53

http://blog.gasoo.cn/?p=5

1、安装MySQL和PHP连接MySQL数据库的包:

  1. yum -y install mysql mysql-server php-mysql

2、安装nginx,php-fpm
因为centos官方没有php-fpm的rpm包 所以咱要想yum安装php-fpm需要在找一个源
(感谢这位兄台我就直接用的这个源)

  1. rpm -ihv http://centos.alt.ru/repository/centos/5/i386/centalt-release-5-3.noarch.rpm
  2. yum install nginx php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator  
在安装php-gd的时候出错
Error: Missing Dependency: libt1.so.5 is needed by package php-gd-5.2.17-37.el5.i686 (CentALT)
需要安装 t1lib 这个包 yum源又没有.操蛋

  1. wget ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/t1lib-5.1.0-9.el5.kb.i386.rpm

  2. rpm -ivh t1lib-5.1.0-9.el5.kb.i386.rpm                         

3、安装MySQL的常用扩展包:

  1. yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql


上面3步安装完成之后,直接就可以启动 nginx  php-fpm   mysql

  1. service nginx start
  2. service php-fpm start
  3. service mysqld start      
在/etc/nginx/nginx.conf配置文件中把php配置项打开:
需要改两个地方
root /usr/share/nginx/html;
解决php解析    No input file specified. 问题   
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;      
解决nginx报错问题                                   

  1. location ~ \.php$ {
  2.             root /usr/share/nginx/html; #这里要改成网站根目录不然会出现 No input file specified.                       
  3.             fastcgi_pass 127.0.0.1:9000;
  4.             fastcgi_index index.php;
  5.             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 这里要改下替换原来/scripts$fastcgi_script_name;
  6.             include fastcgi_params;
  7.         }


然后重启nginx

  1. nginx -t
  2. service nginx restart
      


-------------
如果你想更改nginx默认目录 如 /www/wwwroot 需要在php的location里面添加
root  /www/wwwroot,和你nginx网站根目录路径一样,不然解析php文件会出现
No input file specified.                                                                                                           
nginx配置文件在/etc/nginx/nginx.conf,在这贴出配置(仅server部分   )
                         

  1. server {
  2.     listen 80;
  3.     server_name localhost;


  4.     location / {
  5.         root /www/wwwroot;
  6.         index index.html index.htm;
  7.     }

  8.        location ~ .*\.(php|php5)?$
  9.     {
  10.       root /www/wwwroot; #一定记得加上这一行
  11.       #fastcgi_pass unix:/tmp/php-cgi.sock;
  12.       fastcgi_pass 127.0.0.1:9000;
  13.       fastcgi_index index.php;
  14.       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  15.     }


  16.     error_page 500 502 503 504 /50x.html;
  17.     location = /50x.html {
  18.         root /usr/share/nginx/html;
  19.     }
  20. }



-----------------------------------------作为文章外题.在提供一个nginx的yum安装方法----------------------------                                        


安装nginx
# wget  
# rpm -ivh nginx-release-centos-5-0.el5.ngx.noarch.rpm 
# yum install nginx

如果安装不成功需要安装依赖包
安装依赖包:
#yum install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel

检查 Nginx 是否安装成功:

[root@nowamagic ~]# whereis nginx 
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx

查看 Nginx 版本:
[root@nowamagic ~]# /usr/sbin/nginx -v 
nginx version: nginx/1.4.2


 

阅读(1966) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

徐大保健2014-04-06 21:28:37

高大上