首页 / NGINX / nginx学习三:nginx安装
nginx学习三:nginx安装
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nginx学习三:nginx安装,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5447字,纯文字阅读大概需要8分钟。
内容图文
![nginx学习三:nginx安装](/upload/InfoBanner/zyjiaocheng/930/6b6c9d3136954902b32e2b1d38b4bc65.jpg)
nginx安装
安装方式
- EPEL源
- 不建议,版本低,功能少
- 官方源
- 推荐,官方编译好的,封装成 rpm 包,并提供 yum 源
- 源代码
- 自己下载源代码,使用 configure / make / make install
- 安装费时,复杂
安装步骤
-
配置 nginx yum 源(必须使用官方源)
vim /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true
-
安装nginx,必须安装官方源nginx
yum repolist # 查看有哪些仓库 yum list nginx # 查看 nginx 有哪些 yum install nginx nginx -v # 测试版本 问题一:如果企业之前的Nginx都是通过源码安装,这是需要我们部署新的Nginx服务器,怎么实现? 答: # 官方源 nginx 带的编译选项 nginx -V [root@localhost ~]# nginx -V nginx version: nginx/1.16.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' # 如果企业之前的 nginx 都是通过源码安装,只需要通过 nginx -v -V,就能知道版本及编译选项,安装时: ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' 问题二:选项那么多,必须要配吗?网上搜的博文中选项没那么长 答:选项是根据企业需求来定制,最好按官方的或者企业模板来实现
-
了解Nginx软件的全貌
# 查看整体的目录结构及对应的功能 rpm -ql nginx
nginx安装目录
路径 | 类型 | 作用 |
---|---|---|
/etc/nginx | 配置文件 | nginx主配置文件 |
/etc/nginx/nginx.conf | 配置文件 | nginx主配置文件 |
/etc/nginx/conf.d | 配置文件 | nginx主配置文件 |
/etc/nginx/conf.d/default.conf | 配置文件 | nginx主配置文件 |
/etc/nginx/fastcgi_params | 配置文件 | Cgi、Fastcgi、Uwcgi 配置文件 |
/etc/nginx/scgi_params | 配置文件 | Cgi、Fastcgi、Uwcgi 配置文件 |
/etc/nginx/uwsgi_params | 配置文件 | Cgi、Fastcgi、Uwcgi 配置文件 |
/etc/nginx/win-utf | 配置文件 | Nginx编码转换映射文件 |
/etc/nginx/koi-utf | 配置文件 | Nginx编码转换映射文件 |
/etc/nginx/koi-win | 配置文件 | Nginx编码转换映射文件 |
/etc/nginx/mime.types | 配置文件 | http协议的Content-Type与扩展名 |
/usr/lib/systemd/system/nginx.service | 配置文件 | 配置系统守护进程管理器 |
/etc/logrotate.d/nginx | 配置文件 | Nginx日志轮询,日志切割 |
/usr/sbin/nginx | 命令 | Nginx 终端管理命令 |
/usr/sbin/nginx-debug | 命令 | Nginx 终端管理命令 |
/etc/nginx/modules | 目录 | Nginx模块目录 |
/usr/lib64/nginx | 目录 | Nginx模块目录 |
/usr/lib64/nginx/modules | 目录 | Nginx模块目录 |
/usr/share/nginx | 目录 | Nginx默认站点目录 |
/usr/share/nginx/html | 目录 | Nginx默认站点目录 |
/usr/share/nginx/html/50x.html | 目录 | Nginx默认站点目录 |
/usr/share/nginx/html/index.html | 目录 | Nginx默认站点目录 |
/usr/share/doc/nginx-1.16.1 | 目录 | Nginx的帮助手册 |
/usr/share/man/man8/nginx.8.gz | 目录 | Nginx的帮助手册 |
/var/cache/nginx | 目录 | Nginx的缓存目录 |
/var/log/nginx | 目录 | Nginx的日志目录 |
/etc/logrotate.d/nginx
- 配置文件 Nginx日志轮询,日志切割
- 所有日志都在同一个文件,日志文件会很大,因此,这是必须做的一件事
- tail /var/log/nginx/access.log
/usr/sbin/nginx
- nginx -s reload
/usr/lib/systemd/system/nginx.service
- systemctl reload nginx
内容总结
以上是互联网集市为您收集整理的nginx学习三:nginx安装全部内容,希望文章能够帮你解决nginx学习三:nginx安装所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。