Nginx的编译安装(安装自定义模块)
warning 这篇文章距离上次更新于1242天前,文中部分信息可能已失效,请自行甄别无效内容。
准备
- 安装必要的依赖
yum install -y gcc gcc-c++
yum install -y pcre pcre-devel openssl openssl-devel zlib zlib-devel
- 创建运行nginx的用户(如果想以root用户运行nginx,则需要更改后续的编译配置)
useradd -s /sbin/nologin -M nginx
# 查看nginx的身份
id nginx
- 下载并解压自定义模块(此处举例NCHAN)
https://github.com/slact/nchan/archive/v1.1.14.tar.gz
tar -zxvf v1.1.14.tar.gz
下载并解压nginxwget https://github.com/nginx/nginx/archive/release-1.13.5.tar.gz
tar -zxvf release-1.13.5.tar.gz
编译并添加第三方模块
- 编译配置
- 以root用户运行:更改user和group为root
- 自定义模块路径:add-module
- 配置文件路径:prefix
- 安装路径:sbin-path
. auto/configure \
--user=root \
--group=root \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--without-http_fastcgi_module \
--add-module=/home/nginx/nchan-1.1.14
- 编译并安装
make && make install
Nginx配置文件修改
- 此处配置第三方模块Nchan,如无需配置可跳过
http {
server {
listen 80;
location = /sub {
nchan_subscriber;
nchan_channel_id foobar;
}
location = /pub {
nchan_publisher;
nchan_channel_id foobar;
}
}
}
运行Nginx# cent7 OS 需要关闭防火墙
systemctl stop firewalld
nginx -c /etc/nginx/nginx.conf
yum install -y gcc gcc-c++
yum install -y pcre pcre-devel openssl openssl-devel zlib zlib-devel
useradd -s /sbin/nologin -M nginx
# 查看nginx的身份
id nginx
https://github.com/slact/nchan/archive/v1.1.14.tar.gz
tar -zxvf v1.1.14.tar.gz
wget https://github.com/nginx/nginx/archive/release-1.13.5.tar.gz
tar -zxvf release-1.13.5.tar.gz
编译并添加第三方模块
- 编译配置
- 以root用户运行:更改user和group为root
- 自定义模块路径:add-module
- 配置文件路径:prefix
- 安装路径:sbin-path
. auto/configure \
--user=root \
--group=root \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--without-http_fastcgi_module \
--add-module=/home/nginx/nchan-1.1.14
- 编译并安装
make && make install
Nginx配置文件修改
- 此处配置第三方模块Nchan,如无需配置可跳过
http {
server {
listen 80;
location = /sub {
nchan_subscriber;
nchan_channel_id foobar;
}
location = /pub {
nchan_publisher;
nchan_channel_id foobar;
}
}
}
运行Nginx# cent7 OS 需要关闭防火墙
systemctl stop firewalld
nginx -c /etc/nginx/nginx.conf
- 以root用户运行:更改user和group为root
- 自定义模块路径:add-module
- 配置文件路径:prefix
- 安装路径:sbin-path
. auto/configure \
--user=root \
--group=root \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--without-http_fastcgi_module \
--add-module=/home/nginx/nchan-1.1.14
make && make install
- 此处配置第三方模块Nchan,如无需配置可跳过
http {
server {
listen 80;
location = /sub {
nchan_subscriber;
nchan_channel_id foobar;
}
location = /pub {
nchan_publisher;
nchan_channel_id foobar;
}
}
}
运行Nginx# cent7 OS 需要关闭防火墙
systemctl stop firewalld
nginx -c /etc/nginx/nginx.conf
# cent7 OS 需要关闭防火墙
systemctl stop firewalld
nginx -c /etc/nginx/nginx.conf
阅读:
508
分类:
杂锦记录
创建时间:
2018-10-15 16:58:55
更新时间:
2018-12-28 10:17:43
博文目录
[[replyMessage== null?"发表评论":"@" + replyMessage.m_author]]
account_circle
email
web_asset
textsms
评论列表([[messageResponse.total]])
[[messageItem.m_author]]
[[messageItem.m_author]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]]
[[subMessage.m_author]]
@
[[subMessage.parent_message.m_author]]
[[subMessage.parent_message.m_author]]
[[getEnviron(messageItem.m_environ)]]