nginx-1.2.2 + mysql-5.5.24 + php-5.4.4

1、安装nginx
yum -y install pcre-devel  
  1. groupadd -r nginx  
  2. useradd -r -g nginx -s /sbin/nologin -M nginx
  3. # tar xf nginx-1.2.2.tar.gz
    # cd nginx-1.2.2 
  4. ./configure \  
  5.   --prefix=/usr \  
  6.   --sbin-path=/usr/sbin/nginx \  
  7.   --conf-path=/etc/nginx/nginx.conf \  
  8.   --error-log-path=/var/log/nginx/error.log \  
  9.   --http-log-path=/var/log/nginx/access.log \  
  10.   --pid-path=/var/run/nginx/nginx.pid  \  
  11.   --lock-path=/var/lock/nginx.lock \  
  12.   --user=nginx \  
  13.   --group=nginx \  
  14.   --with-http_ssl_module \  
  15.   --with-http_flv_module \  
  16.   --with-http_stub_status_module \  
  17.   --with-http_gzip_static_module \  
  18.   --http-client-body-temp-path=/var/tmp/nginx/client/ \  
  19.   --http-proxy-temp-path=/var/tmp/nginx/proxy/ \  
  20.   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \  
  21.   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \  
  22.   --http-scgi-temp-path=/var/tmp/nginx/scgi \  
  23.   --with-pcre  
  24. make && make install  
  25.  

为nginx提供启动脚本/etc/rc.d/init.d/nginx,内容前面已经有过了,这里不贴了:
# chmod +x /etc/rc.d/init.d/nginx
# service nginx start

2、安装mysql-5.5.24

 
 
  1.  groupadd -r mysql  
  2.  useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql  
  3.  
  4. tar xf mysql-5.5.24-linux2.6-i686.tar.gz -C /usr/local/  
  5. cd /usr/local/  
  6. ln -s mysql-5.5.24-linux2.6-i686/ mysql  
  7. cd mysql  
  8. chown -R mysql.mysql .  
  9.  
  10. scripts/mysql_install_db --user=mysql --datadir=/mydata/data  
  11. chown -R root 

复制主配置文件,并编辑修改
# cp support-files/my-large.cnf  /etc/my.cnf
# vim /etc/my.cnf
thread_concurrency = 2  //为CPU的个数乘以2
datadir = /mydata/data  //需要手动添加

复制service启动脚本
 

 
 
  1. cp support-files/mysql.server /etc/rc.d/init.d/mysqld  
  2.  
  3. service mysqld restart  
  4. chkconfig --add mysqld  
  5. chkconfig mysqld on  
  6.  
  7. export PATH=/usr/local/mysql/bin/:$PATH  
  8. echo '/usr/local/mysql/lib/' > /etc/ld.so.conf  
  9. ldconfig  


3、安装php-5.4.4
这里的需要更新这几个软件包
libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpm
mhash-0.9.2-6.el5.i386.rpm
mhash-devel-0.9.2-6.el5.i386.rpm

 

 
 
  1. tar -jxvf php-5.4.4.tar.bz2   
  2. cd php-5.4.4  
  3. ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets --enable-sysvshm  --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml  --with-mhash --with-mcrypt  --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php --with-bz2 --with-curl  
  4. make   
  5. make install  
  6.  
  7. 复制主配置文件  
  8. cp php.ini-production /etc/php.ini  
  9.  
  10. 服务脚本  
  11. cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm  
  12. chmod +x /etc/rc.d/init.d/php-fpm   
  13.  
  14. 修改php-fpm配置文件  
  15. cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf  
  16. vim /usr/local/php/etc/php-fpm.conf  
  17. pid run/php-fpm.pid  
  18. pm.max_children 50   最多多少子进程  
  19. pm.start_servers 5   刚开始启动多少进程  
  20. pm.min_spare_servers 2  最少多少空闲进程  
  21. pm.max_spare_servers 8  最多多少空闲进程  
  22.  
  23. service php-fpm start 

编辑/etc/nginx/nginx.conf,启用如下选项:
 

 
 
  1. location \.php$ {  
  2.             root           html;  
  3.             fastcgi_pass   127.0.0.1:9000;  
  4.             fastcgi_index  index.php;  
  5.             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
  6.             include        fastcgi_params;  
  7.         }  

编辑/etc/nginx/fastcgi_params,添加修改如下内容:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

添加php格式的主页,如下所示:
location / {
            root   html;
            index  index.php index.html index.htm;
        }
        
重启服务:
# service nginx restart

写入测试文件,访问查看
# cat /usr/html/index.php 
<?php
phpinfo();
?>

http://peaceweb.blog.51cto.com/3226037/930286

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值