Nginx 编译安装-1.61.1

摘要:
准备编译安装基础环境[root@node1~]#yuminstall-yvimlrzsztreescreenpsmisclsoftcpdumpwgetntpdategccgcc-c++glibcglibc-develpcrepcre-developensslopenssl-develsystemd-develnet-toolsiotopbczipunzipzlib-develbash-comple

准备编译安装基础环境

[root@node1 ~]# yum install -yvim lrzsz tree screen psmisc lsof tcpdump wget ntpdate gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel net-tools iotop bc zip unzip zlib-devel bash-completion nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed

解压缩 nginx包

[root@node1 ~]# tar xf nginx-1.16.1.tar.gz

编译安装

[root@node1 ~]# cd nginx-1.16.1/

[root@node1 nginx-1.16.1]# ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-debug

[root@node1 nginx-1.16.1]#make && make install

创建nginx系统账户

[root@node1 ~]# useradd nginx -s /sbin/nologin

更改 nginx安装目录所属主和所属组为nginx

[root@node1 ~]# chown nginx.nginx -R /apps/nginx

编写nginx自启动脚本

[root@node1 ~]#vim /usr/lib/systemd/system/nginx.service

[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/apps/nginx/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /apps/nginx/logs/nginx.pid
ExecStartPre=/apps/nginx/sbin/nginx -t
ExecStart=/apps/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target

启动nginx,并设为开机自启

[root@node1 ~]# systemctl daemon-reload

[root@node1 ~]# systemctl start nginx

[root@node1 ~]# ss -ntl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 100 127.0.0.1:25 *:*

LISTEN 0 128 *:111 *:*

LISTEN 0 128 *:80 *:*

LISTEN 0 128 *:22 *:*

LISTEN 0 100 [::1]:25 [::]:*

LISTEN 0 128 [::]:111 [::]:*

LISTEN 0 128 [::]:22 [::]:*

[root@node1 ~]# systemctl enable nginx

Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

免责声明:文章转载自《Nginx 编译安装-1.61.1》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇vim定制配色方案【推荐系统实战】:C++实现基于用户的协同过滤(UserCollaborativeFilter)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Nginx(二)-服务模式运行nginx之WINSW

虽然使用命令行控制ngix很简单,但是如果作为一个服务工作的话能更方便地启动、停止或者设置依赖项。 这里使用开源项目Windows Service Wrapper来实现。 github下载地址:https://github.com/kohsuke/winsw/releases .netframework2.0 选择 WinSW.NET2.exe .net...

Ansible入门系列--playbook

一、playbook基础 1、playbook是由一个或多个"play"组成的列表 2、play的主要功能在于将预定义的一组主机,装扮成事先通过ansible中的task定义好的角色。Task实际是调用ansible的一个module,将多个play组织在一个playbook中,即可以让它们联合起来,按事先编排的机制执行预定义的动作 3、Playbook采...

docker一键搭建Nginx+PHP环境(含自动部署命令)

文章的主要部分是一步一步的教程,文章的最后是我整理好的一键安装命令,自动下载并安装docker,构建镜像,启动容器集群(压缩包内注释覆盖范围达到80%) 大家可以看完教程亲自尝试下,也可以直接执行一键安装命令,整个过程大概10分钟左右,我在四台不同的机器上执行过该命令,由于网络原因,5-15分钟不等。 如本文章内容与通过一键安装下载的不同,以一键安装的为...

谷粒商城学习——P124 es 自定义扩展词库

P122中安装的ik分词器, 本身默认的词库并不支持一些新的词汇,这就需要修改ik分词器的配置文件,指定远程词库进行扩展词库。ik分词器向远程发送请求要到最新的单词,这样最新的单词就会做为新的词源远行分解。可以给nginx发送请求,nginx反回最新词库。 虚拟机装nginx,内存不够,先将虚拟机关机,打开设置,将内存调到3075,然后重启      然...

nginx 及 tomcat 端口冲突问题

nginx 监听 80 转发 8088 tomcat 原先通过80 及 8088 都能访问,区别是 80就走nginx转发,8088则直接走tomcat 证据为: 80端口,nginx强行过滤掉css和js后,页面出来无样式和响应,而走8088的话,直接走tomcat,页面完整 再回到主题:原先80及8088都能访问,突然就不能访问了,百思不得其解,最后...

1.初识nginx

​在一个遥远的乡村发生了一件事,村里的邮差老王要退休,同时宣布小张成为新一任的邮差,继续为村民服务。这里的村民生活的nginx帝国地域辽阔,人口众多。帝国和百姓沟通的媒介就是各村的邮差。村民平时遇到问题只需要交给邮差,国王就会迅速将处理 a结果交由邮差带回。 这天村民李二将一张名为”https://xxx.com/abc?name=li“ 的凭条交给了小张...