当前位置:首页 » 编程软件 » 编译nginx

编译nginx

发布时间: 2022-01-09 04:10:46

编译Nginx需要指定安装路径,怎么才能使编译的程序在哪个目录都能运行呢

  1. 配置环境变量
  2. 希望可以帮助你,请采纳,谢谢

㈡ 如何避免编译nginx

如果不想编译nginx,可以通过使用yum源的方式进行安装。
注:需要网络通信正常并且epel源有效,参考命令yum install nginx。

㈢ Nginx编译后修改路径问题

error.log在nginx.conf里面重新指定,就固定设置在/tmp吧,linux基本都有的位置
其它几个temp要在编译时指定,如

--http-client-body-temp-path=/tmp/client_body_temp
--http-proxy-temp-path=/tmp/proxy_temp
--http-fastcgi-temp-path=/tmp/fastcgi_temp

㈣ ubuntu怎么编译nginx

解压nginx的tar包,进入解压后的文件夹里,如果要安装到其他路径的话,修改configure文件里的prefix的值然后执行./configure,或者直接使用./configure --prefix=/xx/xx/xxx来指定,安装路径然后make -j2,如果你的处理器核多,可以增大数字,再然后就是make & make install了。
要注意的是./configure后面可以跟随很多参数配置:
比如,需要的话可以加上--config-path=/xx/xx/xxx/nginx.conf指定nginx的服务器配置文件路径;
--add-mole增加模块,比如luz、pagespeed、upstream等等,这些都可以在官网上查到。

㈤ nginx编译的时候是动态编译还是静态的

静态编译与动态编译的区别:
1、动态编译的可执行文件需要附带一个的动态链接库,在执行时,需要调用其对应动态链接库中的命令。
所以其优点一方面是缩小了执行文件本身的体积,另一方面是加快了编译速度,节省了系统资源。
缺点一是哪怕是很简单的程序,只用到了链接库中的一两条命令,也需要附带一个相对庞大的链接库;二是如果其他计算机上没有安装对应的运行库,则用动态编译的可执行文件就不能运行。
2、静态编译就是编译器在编译可执行文件的时候,将可执行文件需要调用的对应动态链接库(.so)中的部分提取出来,链接到可执行文件中去,使可执行文件在运行的时候不依赖于动态链接库。所以其优缺点与动态编译的可执行文件正好互补。

㈥ 怎么用编译后的nginx

测试的话可以进入命令路径/绝对路径启动,一般建议配置成服务方便控制+设置开机启动。

㈦ 如何在linux下编译nginx

安装nginx

1.下载

2.解压

复制代码代码如下:

tar -zxvf nginx-1.7.0.tar.gz

3.编译和安装

执行如下命令:

#cdnginx-1.7.0#./configure--prefix=/usr/local/nginx-1.7.0--with-http_ssl_mole--with-http_spdy_mole--with-http_stub_status_mole--with-pcre
–with-http_stub_status_mole:支持nginx状态查询–with-http_ssl_mole:支持https–with-http_spdy_mole:支持google的spdy,想了解请网络spdy,这个必须有ssl的支持–with-pcre:为了支持rewrite重写功能,必须制定pcre

最后输出如下内容,表示configure OK了。

㈧ 如何 编译 ngx

一、必要软件准备
1.安装pcre

为了支持rewrite功能,我们需要安装pcre

复制代码代码如下:
# yum install pcre* //如过你已经装了,请跳过这一步

2.安装openssl
需要ssl的支持,如果不需要ssl支持,请跳过这一步

复制代码代码如下:
# yum install openssl*

3.gzip 类库安装

复制代码代码如下:
yum install zlib zlib-devel

4.安装wget
下载nginx使用,如果已经安装,跳过这一步

复制代码代码如下:
# yum install wget

二、安装nginx

1.下载

复制代码代码如下:
wget http://nginx.org/download/nginx-1.7.0.tar.gz

2.解压

复制代码代码如下:

tar -zxvf nginx-1.7.0.tar.gz

3.编译和安装
执行如下命令:

复制代码代码如下:

# cd nginx-1.7.0
# ./configure --prefix=/usr/local/nginx-1.7.0 \
--with-http_ssl_mole --with-http_spdy_mole \
--with-http_stub_status_mole --with-pcre

–with-http_stub_status_mole:支持nginx状态查询
–with-http_ssl_mole:支持https
–with-http_spdy_mole:支持google的spdy,想了解请网络spdy,这个必须有ssl的支持
–with-pcre:为了支持rewrite重写功能,必须制定pcre

最后输出如下内容,表示configure OK了。

复制代码代码如下:

checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx-1.7.0"
nginx binary file: "/usr/local/nginx-1.7.0/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx-1.7.0/conf"
nginx configuration file: "/usr/local/nginx-1.7.0/conf/nginx.conf"
nginx pid file: "/usr/local/nginx-1.7.0/logs/nginx.pid"
nginx error log file: "/usr/local/nginx-1.7.0/logs/error.log"
nginx http access log file: "/usr/local/nginx-1.7.0/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
# make //确定你的服务器有安装make,如果没有安装请执行yum install make

# make install

三、启动、关闭、重置nginx
启动:直接执行以下命令,nginx就启动了,不需要改任何配置文件,nginx配置多域名虚拟主机请参考后续文章.

复制代码代码如下:
/usr/local/nginx-1.7.0/sbin/nginx

试试访问:直接使用curl命令来读取web信息

复制代码代码如下:

[root@ns conf]
# curl -s http://localhost | grep nginx.com
nginx.com.

关闭:

复制代码代码如下:
/usr/local/nginx-1.7.0/sbin/nginx -s stop

重置:当你有修改配置文件的时候,只需要reload以下即可

复制代码代码如下:
/usr/local/nginx-1.7.0/sbin/nginx -s reload

整个nginx的安装就到这里结束了。

四、nginx编译参数详解

复制代码代码如下:

–prefix= 指向安装目录
–sbin-path 指向(执行)程序文件(nginx)
–conf-path= 指向配置文件(nginx.conf)
–error-log-path= 指向错误日志目录
–pid-path= 指向pid文件(nginx.pid)
–lock-path= 指向lock文件(nginx.lock)(安装文件锁定,防止安装文件被别人利用,或自己误操作。)
–user= 指定程序运行时的非特权用户
–group= 指定程序运行时的非特权用户组
–builddir= 指向编译目录
–with-rtsig_mole 启用rtsig模块支持(实时信号)
–with-select_mole 启用select模块支持(一种轮询模式,不推荐在高载环境下使用)禁用:–without-select_mole
–with-poll_mole 启用poll模块支持(功能与select相同,与select特性相同,为一种轮询模式,不推荐在高载环境下使用)
–with-file-aio 启用file aio支持(一种APL文件传输格式)
–with-ipv6 启用ipv6支持
–with-http_ssl_mole 启用ngx_http_ssl_mole支持(使支持https请求,需已安装openssl)
–with-http_realip_mole 启用ngx_http_realip_mole支持(这个模块允许从请求标头更改客户端的IP地址值,默认为关)
–with-http_addition_mole 启用ngx_http_addition_mole支持(作为一个输出过滤器,支持不完全缓冲,分部分响应请求)
–with-http_xslt_mole 启用ngx_http_xslt_mole支持(过滤转换XML请求)
–with-http_image_filter_mole 启用ngx_http_image_filter_mole支持(传输JPEG/GIF/PNG 图片的一个过滤器)(默认为不启用。gd库要用到)
–with-http_geoip_mole 启用ngx_http_geoip_mole支持(该模块创建基于与MaxMind GeoIP二进制文件相配的客户端IP地址的ngx_http_geoip_mole变量)
–with-http_sub_mole 启用ngx_http_sub_mole支持(允许用一些其他文本替换nginx响应中的一些文本)
–with-http_dav_mole 启用ngx_http_dav_mole支持(增加PUT,DELETE,MKCOL:创建集合,COPY和MOVE方法)默认情况下为关闭,需编译开启
–with-http_flv_mole 启用ngx_http_flv_mole支持(提供寻求内存使用基于时间的偏移量文件)
–with-http_gzip_static_mole 启用ngx_http_gzip_static_mole支持(在线实时压缩输出数据流)
–with-http_random_index_mole 启用ngx_http_random_index_mole支持(从目录中随机挑选一个目录索引)
–with-http_secure_link_mole 启用ngx_http_secure_link_mole支持(计算和检查要求所需的安全链接网址)
–with-http_degradation_mole 启用ngx_http_degradation_mole支持(允许在内存不足的情况下返回204或444码)
–with-http_stub_status_mole 启用ngx_http_stub_status_mole支持(获取nginx自上次启动以来的工作状态)
–without-http_charset_mole 禁用ngx_http_charset_mole支持(重新编码web页面,但只能是一个方向–服务器端到客户端,并且只有一个字节的编码可以被重新编码)
–without-http_gzip_mole 禁用ngx_http_gzip_mole支持(该模块同-with-http_gzip_static_mole功能一样)
–without-http_ssi_mole 禁用ngx_http_ssi_mole支持(该模块提供了一个在输入端处理处理服务器包含文件(SSI)的过滤器,目前支持SSI命令的列表是不完整的)
–without-http_userid_mole 禁用ngx_http_userid_mole支持(该模块用来处理用来确定客户端后续请求的cookies)
–without-http_access_mole 禁用ngx_http_access_mole支持(该模块提供了一个简单的基于主机的访问控制。允许/拒绝基于ip地址)
–without-http_auth_basic_mole禁用ngx_http_auth_basic_mole(该模块是可以使用用户名和密码基于http基本认证方法来保护你的站点或其部分内容)
–without-http_autoindex_mole 禁用disable ngx_http_autoindex_mole支持(该模块用于自动生成目录列表,只在ngx_http_index_mole模块未找到索引文件时发出请求。)
–without-http_geo_mole 禁用ngx_http_geo_mole支持(创建一些变量,其值依赖于客户端的IP地址)
–without-http_map_mole 禁用ngx_http_map_mole支持(使用任意的键/值对设置配置变量)
–without-http_split_clients_mole 禁用ngx_http_split_clients_mole支持(该模块用来基于某些条件划分用户。条件如:ip地址、报头、cookies等等)
–without-http_referer_mole 禁用disable ngx_http_referer_mole支持(该模块用来过滤请求,拒绝报头中Referer值不正确的请求)
–without-http_rewrite_mole 禁用ngx_http_rewrite_mole支持(该模块允许使用正则表达式改变URI,并且根据变量来转向以及选择配置。如果在server级别设置该选项,那么他们将在 location之前生效。如果在location还有更进一步的重写规则,location部分的规则依然会被执行。如果这个URI重写是因为location部分的规则造成的,那么 location部分会再次被执行作为新的URI。 这个循环会执行10次,然后Nginx会返回一个500错误。)
–without-http_proxy_mole 禁用ngx_http_proxy_mole支持(有关代理服务器
–without-http_fastcgi_mole 禁用ngx_http_fastcgi_mole支持(该模块允许Nginx 与FastCGI 进程交互,并通过传递参数来控制FastCGI 进程工作。 )FastCGI一个常驻型的公共网关接口。
–without-http_uwsgi_mole 禁用ngx_http_uwsgi_mole支持(该模块用来医用uwsgi协议,uWSGI服务器相关)
–without-http_scgi_mole 禁用ngx_http_scgi_mole支持(该模块用来启用SCGI协议支持,SCGI协议是CGI协议的替代。它是一种应用程序与HTTP服务接口标准。它有些像FastCGI但他的设计 更容易实现。)
–without-http_memcached_mole 禁用ngx_http_memcached_mole支持(该模块用来提供简单的缓存,以提高系统效率)
-without-http_limit_zone_mole 禁用ngx_http_limit_zone_mole支持(该模块可以针对条件,进行会话的并发连接数控制)
–without-http_limit_req_mole 禁用ngx_http_limit_req_mole支持(该模块允许你对于一个地址进行请求数量的限制用一个给定的session或一个特定的事件)
–without-http_empty_gif_mole 禁用ngx_http_empty_gif_mole支持(该模块在内存中常驻了一个1*1的透明GIF图像,可以被非常快速的调用)
–without-http_browser_mole 禁用ngx_http_browser_mole支持(该模块用来创建依赖于请求报头的值。如果浏览器为modern ,则$modern_browser等于modern_browser_value指令分配的值;如 果浏览器为old,则$ancient_browser等于 ancient_browser_value指令分配的值;如果浏览器为 MSIE中的任意版本,则 $msie等于1)
–without-http_upstream_ip_hash_mole 禁用ngx_http_upstream_ip_hash_mole支持(该模块用于简单的负载均衡)
–with-http_perl_mole 启用ngx_http_perl_mole支持(该模块使nginx可以直接使用perl或通过ssi调用perl)
–with-perl_moles_path= 设定perl模块路径
–with-perl= 设定perl库文件路径
–http-log-path= 设定access log路径
–http-client-body-temp-path= 设定http客户端请求临时文件路径
–http-proxy-temp-path= 设定http代理临时文件路径
–http-fastcgi-temp-path= 设定http fastcgi临时文件路径
–http-uwsgi-temp-path= 设定http uwsgi临时文件路径
–http-scgi-temp-path= 设定http scgi临时文件路径
-without-http 禁用http server功能
–without-http-cache 禁用http cache功能
–with-mail 启用POP3/IMAP4/SMTP代理模块支持
–with-mail_ssl_mole 启用ngx_mail_ssl_mole支持
–without-mail_pop3_mole 禁用pop3协议(POP3即邮局协议的第3个版本,它是规定个人计算机如何连接到互联网上的邮件服务器进行收发邮件的协议。是因特网电子邮件的第一个离线协议标 准,POP3协议允许用户从服务器上把邮件存储到本地主机上,同时根据客户端的操作删除或保存在邮件服务器上的邮件。POP3协议是TCP/IP协议族中的一员,主要用于 支持使用客户端远程管理在服务器上的电子邮件)
–without-mail_imap_mole 禁用imap协议(一种邮件获取协议。它的主要作用是邮件客户端可以通过这种协议从邮件服务器上获取邮件的信息,下载邮件等。IMAP协议运行在TCP/IP协议之上, 使用的端口是143。它与POP3协议的主要区别是用户可以不用把所有的邮件全部下载,可以通过客户端直接对服务器上的邮件进行操作。)
–without-mail_smtp_mole 禁用smtp协议(SMTP即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式。SMTP协议属于TCP/IP协议族,它帮助每台计算机在发送或中转信件时找到下一个目的地。)
–with-google_perftools_mole 启用ngx_google_perftools_mole支持(调试用,剖析程序性能瓶颈)
–with-cpp_test_mole 启用ngx_cpp_test_mole支持
–add-mole= 启用外部模块支持
–with-cc= 指向C编译器路径
–with-cpp= 指向C预处理路径
–with-cc-opt= 设置C编译器参数(PCRE库,需要指定–with-cc-opt=”-I /usr/local/include”,如果使用select()函数则需要同时增加文件描述符数量,可以通过–with-cc- opt=”-D FD_SETSIZE=2048”指定。)
–with-ld-opt= 设置连接文件参数。(PCRE库,需要指定–with-ld-opt=”-L /usr/local/lib”。)
–with-cpu-opt= 指定编译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
–without-pcre 禁用pcre库
–with-pcre 启用pcre库
–with-pcre= 指向pcre库文件目录
–with-pcre-opt= 在编译时为pcre库设置附加参数
–with-md5= 指向md5库文件目录(消息摘要算法第五版,用以提供消息的完整性保护)
–with-md5-opt= 在编译时为md5库设置附加参数
–with-md5-asm 使用md5汇编源
–with-sha1= 指向sha1库目录(数字签名算法,主要用于数字签名)
–with-sha1-opt= 在编译时为sha1库设置附加参数
–with-sha1-asm 使用sha1汇编源
–with-zlib= 指向zlib库目录
–with-zlib-opt= 在编译时为zlib设置附加参数
–with-zlib-asm= 为指定的CPU使用zlib汇编源进行优化,CPU类型为pentium, pentiumpro
–with-libatomic 为原子内存的更新操作的实现提供一个架构
–with-libatomic= 指向libatomic_ops安装目录
–with-openssl= 指向openssl安装目录
–with-openssl-opt 在编译时为openssl设置附加参数
–with-debug 启用debug日志

㈨ window版本的nginx能重新编译吗如何添加新的模块呢

找到安装nginx的源码根目录,如果没有的话下载新的源码
http://nginx.org
tar xvzf nginx-1.3.2.tar.gz
查看ngixn版本极其编译参数
/usr/local/nginx/sbin/nginx -V
进入nginx源码目录
cd nginx-1.3.2
以下是重新编译的代码和模块
./configure --prefix=/usr/local/nginx--with-http_stub_status_mole
--with-http_ssl_mole --with-file-aio --with-http_realip_mole
make 千万别make install,否则就覆盖安装了
make完之后在objs目录下就多了个nginx,这个就是新版本的程序了
备份旧的nginx程序
cp /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.bak
把新的nginx程序覆盖旧的
cp objs/nginx /usr/local/nginx/sbin/nginx
测试新的nginx程序是否正确
/usr/local/nginx/sbin/nginx -t
nginx: theconfiguration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx:configuration file /usr/local/nginx/conf/nginx.conf test issuccessful
平滑重启nginx
/usr/local/nginx/sbin/nginx -s reload
查看ngixn版本极其编译参数
/usr/local/nginx/sbin/nginx -V
这是我重新编译的代码:
./configure --prefix=/usr/local/nginx --with-google_perftools_mole
--user=www --group=www --with-http_stub_status_mole
--with-http_gzip_static_mole --with-openssl=/usr/
--with-pcre=/mydata/soft/pcre-8.31

热点内容
linux查看svn密码 发布:2024-05-03 18:12:47 浏览:803
地铁逃生怎么进入游戏安卓 发布:2024-05-03 17:49:35 浏览:992
aws云存储 发布:2024-05-03 17:48:50 浏览:954
安卓微信王者号怎么转成苹果 发布:2024-05-03 17:44:38 浏览:745
原子类源码 发布:2024-05-03 17:44:19 浏览:165
安卓浏览图片如何全屏 发布:2024-05-03 17:24:08 浏览:104
传奇仓库脚本 发布:2024-05-03 17:23:56 浏览:541
2010数据库技术及应用 发布:2024-05-03 17:21:51 浏览:921
小米账号密码忘了怎么 发布:2024-05-03 17:17:44 浏览:780
皇家农场脚本 发布:2024-05-03 16:46:41 浏览:458