资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

CentOS6.3下nginx、php-fpm、drupal快速部署

一切本着从简原则来做,能yum/rpm的,坚决不手工编译 :)
本次部署环境基于CentOS 6.3 x86_64系统。
0. 准备工作

创新互联公司长期为近千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为龙泉驿企业提供专业的成都网站制作、成都网站建设,龙泉驿网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。

#更新yum [root@imysql~]#yum-yupdate [root@imysql~]#yuminstalllibaio-devel.x86_64 #drupal8.0需要用到curl模块 [root@imysql~]#yuminstallcurl-devel [root@imysql~]#yum-yinstalllibpng-devellibjpeg-develfreetype-develgmp-devellibxml2-devel

1. 安装nginx

#安装nginx官方yum源包 [root@imysql~]#rpm-ivhhttp://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm [root@imysql~]#yum-yinstallnginx [root@imysql~]#chkconfignginxon

2. 安装php-fpm

#安装phpyum源包 [root@imysql~]#rpm-ivhrpm-Uvhhttp://repo.webtatic.com/yum/el6/latest.rpm [root@imysql~]#yum-yinstallphp54w

3. 配置nginx+php
/etc/nginx/nginx.conf 配置文件可以不用做任何修改。
编辑 /etc/nginx/conf.d/default.conf,以本站为例,配置文件如下:

server{ listen80; server_nameimysql.com*.imysql.com; root/data/www/imysql.cn/; indexindex.phpindex.htmindex.htmlindex.shtml; error_page404/page_not_found; error_page500502503504/page_not_found; location~/.ht{ denyall; } if($fastcgi_script_name~..*/.*php){ return403; } location/{ if(!-e$request_filename){ rewrite^/(.*)$/index.php?q=$1last; } } location~.php${ fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; includefastcgi_params; } location~.*.(gif|jpg|jpeg|png|bmp|swf)${ expires30d; } location~.*.(js|css)?${ expires1h; } location^~/sites/default/files/imagecache/{ indexindex.phpindex.html; if(!-e$request_filename){ rewrite^/(.*)$/index.php?q=$1last;break; } } }

上述配置包括了nginx虚拟主机的配置,以及drupal的rewrite规则配置,简单快速。

4. 启动测试
每次修改完配置文件后,都记得执行下面的命令测试配置文件正确性:

[root@imysql~]#/etc/init.d/nginxconfigtest nginx:theconfigurationfile/etc/nginx/nginx.confsyntaxisok nginx:configurationfile/etc/nginx/nginx.conftestissuccessful

确认配置文件无误后,执行下面的命令重载nginx,使其生效:

[root@imysql~]#/etc/init.d/nginxreload #或者restart [root@imysql~]#/etc/init.d/nginxrestart

大功告成 :)


名称栏目:CentOS6.3下nginx、php-fpm、drupal快速部署
链接分享:http://cdkjz.cn/article/cghdpj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220