nginx+php5-fpm安装

简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
我的博客已迁移到xdoujiang.com请去那边和我交流
一、基础环境
1、 cat  /etc/debian_version 
7.8
 
2、 uname  -r
3.2.0-4-amd64
 
3、ip(eth0)
10.0.0.109
 
4、nginx版本
1.4.7
 
二、安装nginx
1、安装所需要的基础包
apt-get -y  install  libpcre3-dev libpcre3 libssl-dev zlib1g-dev  make
 
2、建立nginx用户
1)groupadd nginx
2) useradd  nginx -g nginx -s  /bin/false
 
3、下载nginx
axel -n 10 http: //nginx .org /download/nginx-1 .4.7. tar .gz
 
4、解压
tar  zxvf nginx-1.4.7. tar .gz &&  cd  nginx-1.4.7
 
5、编译三部曲
1). /configure  --prefix= /opt/nginx  --user=nginx --group=nginx --with-http_ssl_module
2) make  &&  make  install
 
6、参数说明
--prefix= /opt/nginx     将安装路径指定在 /opt/nginx 
http_ssl_module         https协议模块
http_gzip_module        压缩的HTTP服务器的响应模块
http_rewrite_module     重写模块
--user=nginx            nginx用户 
--group=nginx           nginx组
 
7、为了方便 弄个软链接
ln  -s  /opt/nginx/sbin/nginx  /usr/local/sbin/nginx
 
8、修改nginx配置文件以支持php-fpm
1)先备份下
cp  /opt/nginx/conf/nginx .conf  /opt/nginx/conf/nginx .conf.bak
2)修改以下内容
2c2
< user nginx;
---
#user  nobody;
36,39c36,38
<         listen       10.0.0.109:80;
<         server_name  10.0.0.109;
<         access_log  /opt/nginx/logs/10 .0.0.109.access.log;
<         error_log  /opt/nginx/logs/10 .0.0.109.error.log;
---
>         listen       80;
>         server_name  localhost;
66,72c65,71
<         location ~ \.php$ {
<             root           html;
<             fastcgi_pass   unix: /run/shm/php5-fpm .sock;
<             fastcgi_index  index.php;
<             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
<             include        fastcgi_params;
<         }
---
>          #location ~ \.php$ {
>          #    root           html;
>          #    fastcgi_pass   127.0.0.1:9000;
>          #    fastcgi_index  index.php;
>          #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
>          #    include        fastcgi_params;
>          #}
 
9、启动nginx服务
nginx
 
10、查看端口和进程
1) netstat  -tupnl| grep  nginx
tcp        0      0 10.0.0.109:80           0.0.0.0:*               LISTEN      13852 /nginx : master
2) ps  -ef | grep  nginx
root     13852     1  0 22:51 ?        00:00:00 nginx: master process nginx
nginx    13853 13852  0 22:51 ?        00:00:00 nginx: worker process
nginx    13907 13906  0 22:52 ?        00:00:00 php-fpm: pool www                                         
nginx    13908 13906  0 22:52 ?        00:00:00 php-fpm: pool www  
 
PS:
1、停止nginx服务
nginx -s quit
2、重新加载配置
nginx -s reload
 
三、安装php5-fpm
1、安装php5-fpm及php
apt-get -y  install  php5-cli
apt-get -y  install  php5-fpm
 
2、修改php-fpm配置文件
1)先备份下
cp  /etc/php5/fpm/pool .d /www .conf  /etc/php5/fpm/pool .d /www .conf.bak
2)修改以下内容
diff  /etc/php5/fpm/pool .d /www .conf  /etc/php5/fpm/pool .d /www .conf.bak 
22,23c22,23
< user = nginx
< group = nginx
---
> user = www-data
> group = www-data
33c33
< listen =  /run/shm/php5-fpm .sock
---
> listen =  /var/run/php5-fpm .sock
44,46c44,46
< listen.owner = nginx
< listen.group = nginx
< listen.mode = 0660
---
> listen.owner = www-data
> listen.group = www-data
> ;listen.mode = 0660
 
3、重启php-fpm服务
/etc/init .d /php5-fpm  restart
 
4、查看进程
ps  -ef | grep  php
root     13906     1  0 22:52 ?        00:00:00 php-fpm: master process ( /etc/php5/fpm/php-fpm .conf)      
nginx    13907 13906  0 22:52 ?        00:00:00 php-fpm: pool www                                         
nginx    13908 13906  0 22:52 ?        00:00:00 php-fpm: pool www   
 
四、写个php文件测试
cat  /opt/nginx/html/info .php 
<?php
phpinfo();
?>;
 
五、nginx相关模块及参考文章
1、nginx相关模块
ngx_http_core_module
ngx_http_access_module
ngx_http_addition_module
ngx_http_auth_basic_module
ngx_http_auth_request_module
ngx_http_autoindex_module
ngx_http_browser_module
ngx_http_charset_module
ngx_http_dav_module
ngx_http_empty_gif_module
ngx_http_f4f_module
ngx_http_fastcgi_module
ngx_http_flv_module
ngx_http_geo_module
ngx_http_geoip_module
ngx_http_gunzip_module
ngx_http_gzip_module
ngx_http_gzip_static_module
ngx_http_headers_module
ngx_http_hls_module
ngx_http_image_filter_module
ngx_http_index_module
ngx_http_limit_conn_module
ngx_http_limit_req_module
ngx_http_log_module
ngx_http_map_module
ngx_http_memcached_module
ngx_http_mp4_module
ngx_http_perl_module
ngx_http_proxy_module
ngx_http_random_index_module
ngx_http_realip_module
ngx_http_referer_module
ngx_http_rewrite_module
ngx_http_scgi_module
ngx_http_secure_link_module
ngx_http_session_log_module
ngx_http_spdy_module
ngx_http_split_clients_module
ngx_http_ssi_module
ngx_http_ssl_module
ngx_http_status_module
ngx_http_stub_status_module
ngx_http_sub_module
ngx_http_upstream_module
ngx_http_upstream_conf_module
ngx_http_userid_module
ngx_http_uwsgi_module
ngx_http_xslt_module
 
ngx_mail_core_module
ngx_mail_auth_http_module
ngx_mail_proxy_module
ngx_mail_ssl_module
ngx_mail_imap_module
ngx_mail_pop3_module
ngx_mail_smtp_module
 
ngx_stream_core_module
ngx_stream_access_module
ngx_stream_limit_conn_module
ngx_stream_proxy_module
ngx_stream_ssl_module
ngx_stream_upstream_module
 
2、参考文章
http: //nginx .org /en/docs
http: //tengine .taobao.org /nginx_docs/cn/docs/http/ngx_http_core_module .html
 
六、效果

wKioL1WnzcGSj2TZAAPvzqXiyQM055.jpg










本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1675483,如需转载请自行联系原作者
相关文章
今日小结通过aliyun的本地容器镜像部署我的nginx和php环境
简介: 本教程介绍如何基于 Dragonwell 的 Ubuntu 镜像创建一个运行 Nginx 的 Docker 容器。首先从阿里云容器镜像服务拉取基础镜像,然后编写 Dockerfile 确保 Nginx 作为主进程运行,并暴露 80 端口。最后,在包含 Dockerfile 的目录下构建自定义镜像并启动容器,确保 Nginx 在前台运行,避免容器启动后立即退出。通过 `docker build` 和 `docker run` 命令完成整个流程。
154 24
今日小结通过aliyun的本地容器镜像部署我的nginx和php环境
|
26天前
|
利用PHP压缩音频:Linux环境下的ffmpeg简易安装指南
希望这个指南能为你的编程之旅提供帮助。只需记住,每一行代码都像音乐的音符,组合在一起,创造出美妙的旋律。祝你编程愉快!
77 6
os-copilot安装与多项功能测评,帮助开发人员PHP环境排查问题
本文介绍了OS Copilot在ECS上 Alibaba Cloud Linux的安装与使用,并对其多项参数进行了功能测评。OS Copilot是为操作系统提供智能化辅助的工具,支持自动化任务、智能推荐、故障排查等功能。安装时需检查是否已安装(`rpm -q os-copilot`),若未安装则用`yum install os-copilot`命令安装,并配置AccessKey信息连接阿里云服务。通过测试不同参数命令,如`-t`参数,展示了其自动化执行和智能生成回答的能力,显著提升运维效率。
os-copilot安装与多项功能测评,帮助开发人员PHP环境排查问题
|
2月前
|
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
107 20
当你的nginx服务器和php服务器不在一起的时候,这个nginx 的root目录问题
两个服务器的网站代码目录需要对齐,docker容器里面也是一样
docker安装nginx,前端项目运行
通过上述步骤,你可以轻松地在Docker中部署Nginx并运行前端项目。这种方法不仅简化了部署流程,还确保了环境的一致性,提高了开发和运维的效率。确保按步骤操作,并根据项目的具体需求进行相应的配置调整。
363 25
01 入门PHP就来我这-安装phpstudy
路老师的PHP入门教程,带你从零开始学习PHP。首先下载并安装phpStudy,接着配置域名和端口,最后创建并运行第一个PHP文件。内容详实,适合初学者。
130 3
01 入门PHP就来我这-安装phpstudy
|
6月前
|
PHP7 MongDB 安装与使用
10月更文挑战第19天
77 1
PHP7 MongDB 安装与使用
轻松上手Nginx Proxy Manager:安装、配置与实战
Nginx Proxy Manager (NPM) 是一款基于 Nginx 的反向代理管理工具,提供直观的 Web 界面,方便用户配置和管理反向代理、SSL 证书等。本文档介绍了 NPM 的安装步骤,包括 Docker 和 Docker Compose 的安装、Docker Compose 文件的创建与配置、启动服务、访问 Web 管理界面、基本使用方法以及如何申请和配置 SSL 证书,帮助用户快速上手 NPM。
2576 1
nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件,很全
这篇博客文章详细介绍了Nginx的下载、安装、配置以及使用,包括正向代理、反向代理、负载均衡、动静分离等高级功能,并通过具体实例讲解了如何进行配置。
288 4
nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件,很全
下一篇
oss创建bucket
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等