CentOS 6.0 64bit (Basic Server)下安装Nginx1.0.4+PHP 5.3.6+Mysql 5.5.14

1. 安装 CentOS 6.0 64bit (Basic Server)
2.  YUM Packages.
* Tools
  yum install telnet gcc gcc-c++
  yum install libtool
*Nginx
  yum install pcre-devel  zlib-devel
* PHP:
yum install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel

3. MySQL5.5.14
参照博客另外一篇文章 http://koda.iteye.com/blog/890572

4. PHP 5.3.6
1). 编译PHP前传
为了安装GD库到yum安装必要的包(libpng,libjpeg等)还要安装 : jpegsrc.v6b.tar.gz,libpng-1.2.8-config.tar.gz(好像只有tar包)
I. 安装jpegsrc.v6b.tar.gz
下载http://www.filewatcher.com/m/jpegsrc.v6b.tar.gz.613261.0.0.html
进入jpeg-6b的源码目录,然后执行以下步骤:

cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
./configure --enable-shared --enable-static
make
mkdir -p /usr/local/man/man1
make install-lib
make install 


II. 安装libpng-1.2.8-config.tar.gz
下载http://www.filewatcher.com/m/libpng-1.2.8-config.tar.gz.695097.0.0.html

./configure
make
make install

2). 编译PHP

./configure --prefix=/usr/local/php --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-zlib --enable-fpm --enable-mbstring --with-gd --with-curl 
make
make install

3). 配置php-fpm并运行
PHP5.3内置了fastcgi支持。
I.  生成配置文件
   复制$PHP_DIR/etc/php-fpm.conf.default 到$PHP_DIR/etc/php-fpm.conf
   打开一下两行注释:
   pid = run/php-fpm.pid
   pm.start_servers = 20
   pm.min_spare_servers = 5
   pm.max_spare_servers = 35
II.. 启动php-fpm
   $PHP_DIR/sbin/php-fpm
III. 停止php-fpm
   killall -9 php-fpm

IV. 加入到服务中去并每次开机自动启动
  cp  $PHP_SOURCE_DIR/sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm
  chmod 700 /etc/init.d/php-fpm
  chkconfig --add php-fpm
  chkconfig --level 345 php-fpm on
  服务方式启动php-fpm
  service php-fpm restart

5. Nginx
I. tar包安装到/usr/local/nginx

 ./configure --prefix=/usr/local/nginx
 make
 make install

II 启动停止nginx
启动: sbin/nginx (默认使用conf/nginx.conf作为配置文件)
停止: kill `cat /usr/local/nginx/logs/nginx.pid`
III. 令开机自动启动
加入条目
/usr/local/nginx/sbin/nginx 到 /etc/rc.local

IV. 虚拟主机配置
  $NGINX_DIR/conf/nginx.conf,增加如下段
Nginx.conf代码

   server {
        listen       80;
        server_name  *.helixway.me helixway.me;
        root   /var/www;  #注意 root要设置在location /外面, 否则接下来访问PHP将会返回一片空白(状态码404)

        location / {
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

V. 连接fastcgi服务器
这里以www.helixway.me为例,使其支持php
A). 配置文件修改
* 在conf/nginx.conf中的http{ 里加入行:

Nginx.conf代码

  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;

* 在conf/nginx.conf中的server_name 为*.helixway.me的server { 段里加入行:
Nginx.conf代码

 location ~ .*\.(php|php5)?$
  {      
	#fastcgi_pass  unix:/tmp/php-cgi.sock;
	fastcgi_pass  127.0.0.1:9000;
	fastcgi_index index.php;
	include fastcgi.conf;
  }

* 上面配置中include指示符包含了另外一个配置文件fasctcgi.conf,该文件默认存在conf/目录下,一般不需要做任何修改。
B). 重新启动nginx.
  在/var/www/目录下建立php文件测试。

转载于:https://www.cnblogs.com/huangjingzhou/articles/2153573.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值