前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Nginx + PHP(FastCGI)安装配置笔记

Nginx + PHP(FastCGI)安装配置笔记

作者头像
魏杰
发布2022-12-23 18:11:58
4470
发布2022-12-23 18:11:58
举报

这是站长在2011年时一次安装服务器时所记录的Nginx和PHP的安装笔记。安装过程记录的比较简略,仅仅是一个大致的流程,一些细节描述的不够详细,请多多谅解,我会在日后重新整理一份详细的安装过程,本文仅供参考!

软件环境:CentOS 5.7 + PHP 5.2.17 + Nginx 0.8.55

1. 编译安装 PHP 和 PHP-FPM

提示:

  • 安装PHP前应先安装MySQL,具体方法请自行baidu或google;
  • PHP所需支持库的安装这里不做过多介绍,可上网搜索参照相关教程进行安装。
  • http://php-fpm.org/downloads/下载与当前PHP版本对应的PHP-FPM源码包,例如:php-5.2.17-fpm-0.5.14.diff.gz

tar zxvf php-5.2.17.tar.gz gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1 cd php-5.2.17 ./configure –prefix=/usr/local/php/ –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql/ –with-pdo-mysql=/usr/local/mysql/ –with-gd –with-zlib –with-curl –with-jpeg-dir –with-png-dir –with-libxml-dir –with-freetype-dir –with-iconv=/usr/local –with-mcrypt –enable-fastcgi –enable-fpm –enable-xml –enable-mbstring make make install cp php.ini-dist /usr/local/php/etc/php.ini

注意:上面配置PHP编译参数中的–enable-fastcgi是必须开启的。

2. 创建 Nginx 使用的用户和用户组

groupadd www useradd -g www www

3. 创建站点目录并设置权限

mkdir -p /htdocs/www chmod +w /htdocs/www chown -R www:www /htdocs/www

4. 安装 Nginx 所需的 PCRE 库

tar zxvf pcre-8.13.tar.gz cd pcre-8.13 ./configure make make install

5. 安装 Nginx

tar zxvf nginx-0.8.55.tar.gz cd nginx-0.8.55 ./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –user=www –group=www make make install

6. 配置 Nginx,创建虚拟主机

在 nginx.conf 文件的 http{…} 段中,增加一个 server{…} 段,例如下面的代码:

server { listen 80; server_name www.youdomain.com; #你的域名 root /htdocs/www; access_log logs/www.access.log; location / { index index.html index.php; } error_page 500 502 503 504  /50x.html; location = /50x.html { root html; } location ~ .*\.php?$ { fastcgi_pass   127.0.0.1:9000; fastcgi_index  index.php; include        fastcgi.conf; } location ~ /nginx_info { access_log off; stub_status on; } }

注意:上面的配置中,增加了location ~ /nginx_info {…},这样就可以通过http://www.youdomain.com/nginx_info/来查询Nginx的状态信息了。

启动 PHP-FPM

/usr/local/php/sbin/php-fpm start

启动 Nginx

/usr/local/nginx/sbin/nginx

转载请注明:阳光部落原创,更多内容请访问http://www.sunbloger.com/

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2012-02-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档