首页 > 系统相关 >nginx源码编译安装

nginx源码编译安装

时间:2022-10-27 11:37:59浏览次数:39  
标签:http 编译 -- module nginx 源码 usr path

window版本的nginx能重新编译吗?如何添加新的模块呢
找到安装nginx的源码根目录,如果没有的话下载新的源码 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_module--with-http_ssl_module --with-file-aio --with-http_realip_modulemake 千万别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 -tnginx: theconfiguration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: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_module--user=www --group=www --with-http_stub_status_module--with-http_gzip_static_module --with-openssl=/usr/--with-pcre=/mydata/soft/pcre-8.31
怎么样更新nginx版本到1.10
Nginx是通过apt-get的方式安装的,所以我的路径与下载代码再编译、安装的有些不一样,我的升级过程如下
1.进入Downloads文件夹
cd/Downloads
2.下载nginx-1.2.5.tar.gz文件到Downloads文件夹中
3.解压nginx-1.2.5.tar.gz文件
tarzxvfnginx-1.2.5.tar.gz
4.进入ngixn-1.2.5文件夹中
cdnginx-1.2.5
5.查看nginx原来的配置
nginx-V
上面的命令将输出:
--prefix=/etc/nginx--conf-path=/etc/nginx/nginx.conf--error-log-path=/var/log/nginx/error.log--http-client-body-temp-path=/var/lib/nginx/body--http-fastcgi-temp-path=/var/lib/nginx/fastcgi--http-log-path=/var/log/nginx/access.log--http-proxy-temp-path=/var/lib/nginx/proxy--http-scgi-temp-path=/var/lib/nginx/scgi--http-uwsgi-temp-path=/var/lib/nginx/uwsgi--lock-path=/var/lock/nginx.lock--pid-path=/var/run/nginx.pid--with-debug--with-http_addition_module--with-http_dav_module--with-http_geoip_module--with-http_gzip_static_module--with-http_image_filter_module--with-http_realip_module--with-http_stub_status_module--with-http_ssl_module--with-http_sub_module--with-http_xslt_module--with-ipv6--with-sha1=/usr/include/openssl--with-md5=/usr/include/openssl--with-mail--with-mail_ssl_module
6.执行configure命令,后面跟上原来nginx的配置
./configure--prefix=/etc/nginx--conf-path=/etc/nginx/nginx.conf--error-log-path=/var/log/nginx/error.log--http-client-body-temp-path=/var/lib/nginx/body--http-fastcgi-temp-path=/var/lib/nginx/fastcgi--http-log-path=/var/log/nginx/access.log--http-proxy-temp-path=/var/lib/nginx/proxy--http-scgi-temp-path=/var/lib/nginx/scgi--http-uwsgi-temp-path=/var/lib/nginx/uwsgi--lock-path=/var/lock/nginx.lock--pid-path=/var/run/nginx.pid--with-debug--with-http_addition_module--with-http_dav_module--with-http_geoip_module--with-http_gzip_static_module--with-http_image_filter_module--with-http_realip_module--with-http_stub_status_module--with-http_ssl_module--with-http_sub_module--with-http_xslt_module--with-ipv6--with-sha1=/usr/include/openssl--with-md5=/usr/include/openssl--with-mail--with-mail_ssl_module
在执行configure时得到几个错误:
a.配置--with-http_xslt_module时提示theHTTPXSLTmodulerequiresthelibxml2/libxsltlibraries
sudoapt-getinstalllibxml2libxml2-devlibxslt-dev
b.配置--with-http_image_filter_module时提示theHTTPimagefiltermodulerequirestheGDlibrary.
sudoapt-getinstalllibgd2-xpmlibgd2-xpm-dev
c.配置--with-http_geoip_module时提示theGeoIPmodulerequirestheGeoIPlibrary.
sudoapt-getinstallgeoip-databaselibgeoip-dev
d.rewrite需要pcre支持,错误提示:./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.
apt-getinstalllibpcre3libpcre3-dev
7.再执行第6步的configure命令
8.这次没有提示缺少library,执行make令命编译nginx,编译好以后objs目录下多出一个nginx文件,这个就是已编辑好的nginx程序
9.更改旧的nginx程序的名子,并复制新的程序过去,我的旧nginx程序放在/usr/sbin/目录中
mv/usr/sbin/nginx/usr/sbin/nginx-20121122
cpobjs/nginx/usr/sbin/nginx
/usr/sbin/nginx-t
执行/usr/sbin/nginx-t命令检查配置文件并将返回下面的信息:
nginx:theconfigurationfile/etc/nginx/nginx.confsyntaxisok
nginx:configurationfile/etc/nginx/nginx.conftestissuccessful
10.在nginx-1.2.5目录下执行下面的命令来升级nginx
makeupgrade
11.执行makeupgrade得到一个错误:
make:/etc/nginx/sbin/nginx:Commandnotfound
make:***[upgrade]Error127
12.用文本编辑器打开修改nginx-1.2.5目录下名为Makefile的文件,将upgrade节点中的/etc/nginx/sbin/nginx改为/usr/sbin/nginx-t,保存后关闭并重新执行makeupgrade命令
13.执行nginx-v命令,程序的版本号已经是1.2.5,升级完毕.
本回答由网友推荐

标签:http,编译,--,module,nginx,源码,usr,path
From: https://blog.51cto.com/yetaotao/5800558

相关文章

  • nginxhttp转到https没有带端口
    nginxhttps自动跳转成http怎么解决您关闭301跳转,HTTPS自然就无法访问,如果您要HTTPS跳转HTTP,这个是不正确的行为,如果设置会导致搜索引擎蜘蛛混乱,无法确定实际网站,目前搜索......
  • nginxkeepalived和tomcat整合
    最前面两台NGINX+keepalived可不可以同时承担WEB的高可用负载均衡和图片服务器并实现高可用?完全可以实现的nginx可以设置多个server,相互之间互不影响,用keepalived做负载的应......
  • nginxipv6转ipv4
    ipv6only事什么意思IPv6only=on的意思:打开IPv6only网络;IPv6only=off的意思:关闭IPv6only网络;通常在nginx开启IPV6支持配置,使用“nginxipv6only=on”景安网络作为全国首家IP......
  • nginx错误日志解析
    nginx错误日志在哪访问日志的话没有指定路径,在安装目录的logs目录下,指定的话就看到指定什么路径了另外NGINX+PHP的话,错误日志不好找,要开启PHP的日志,可以使用系统日志(/var/......
  • nginx转发到页面白屏
    laravel安装完成后,访问public目录,显示一片空白怎么回事白屏没有错误提示一般是php.ini的display_errors没有启用的问题所以首先确保display_errors已经是On的状态然后打开De......
  • docker安装nginx配置
    编译安装nginx的配置文件的路径在哪这个版本不同,位置还是不同的。我的是nginx-1.9.9版本源码安装,配置文件在conf这个目录里面:/usr/local/nginx/conf/nginx.conf如果你找不见......
  • nginx没有权限
    nginx.conf配置的root目录要什么权限你可以修改nginx配置里的root,比如下面的代码路径是到/data/www读取:server{listen80;server_nametest.abc.com;root/data/www;indexindex......
  • nginx安装配置 linux
    编译安装nginx的配置文件的路径在哪这个版本不同,位置还是不同的。我的是nginx-1.9.9版本源码安装,配置文件在conf这个目录里面:/usr/local/nginx/conf/nginx.conf如果你找不见......
  • nginx配置文件location详解
    Centos7安装nginx完成后发现nginx.conf文件中没有server,只有events{...}和http{...},这是什么问题?在nginx.conf文件同目录的conf.d文件夹下的default.conf文件里面,应该是新......
  • nginx安装反向代理
    centos使用yum安装nginx后如何添加模块1.确认你已经安装在用的nginx信息nginx-V2.下载和此版本相同的nginx源码包并解压tar-xvzfnginx-1.10.3.tar.gz3.更新一下依赖相关包y......