http://blog.gasoo.cn/?p=5
1、安装MySQL和PHP连接MySQL数据库的包:
-
yum -y install mysql mysql-server php-mysql
2、安装nginx,php-fpm
因为centos官方没有php-fpm的rpm包 所以咱要想yum安装php-fpm需要在找一个源
(感谢这位兄台我就直接用的这个源)
-
rpm -ihv http://centos.alt.ru/repository/centos/5/i386/centalt-release-5-3.noarch.rpm
-
-
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源又没有.操蛋
-
wget ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/t1lib-5.1.0-9.el5.kb.i386.rpm
-
-
rpm -ivh t1lib-5.1.0-9.el5.kb.i386.rpm
3、安装MySQL的常用扩展包:
-
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
上面3步安装完成之后,直接就可以启动 nginx php-fpm mysql
-
service nginx start
-
service php-fpm start
-
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报错问题
-
location ~ \.php$ {
-
root /usr/share/nginx/html; #这里要改成网站根目录不然会出现 No input file specified.
-
fastcgi_pass 127.0.0.1:9000;
-
fastcgi_index index.php;
-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 这里要改下替换原来/scripts$fastcgi_script_name;
-
include fastcgi_params;
-
}
然后重启nginx
-
nginx -t
-
service nginx restart
-------------
如果你想更改nginx默认目录 如 /www/wwwroot 需要在php的location里面添加
root /www/wwwroot
,和你nginx网站根目录路径一样,不然解析php文件会出现
No input file specified.
nginx配置文件在/etc/nginx/nginx.conf,在这贴出配置(仅server部分 )
-
server {
-
listen 80;
-
server_name localhost;
-
-
-
location / {
-
root /www/wwwroot;
-
index index.html index.htm;
-
}
-
-
location ~ .*\.(php|php5)?$
-
{
-
root /www/wwwroot; #一定记得加上这一行
-
#fastcgi_pass unix:/tmp/php-cgi.sock;
-
fastcgi_pass 127.0.0.1:9000;
-
fastcgi_index index.php;
-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-
}
-
-
-
error_page 500 502 503 504 /50x.html;
-
location = /50x.html {
-
root /usr/share/nginx/html;
-
}
-
}
-----------------------------------------作为文章外题.在提供一个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
阅读(2037) | 评论(1) | 转发(1) |