首页 技术 正文
技术 2022年11月17日
0 收藏 606 点赞 4,551 浏览 3122 个字

一、下载码源包

1. 获得源码包途径
官方网站,可以获得最新的软件包
Nginx: www.nginx.org

2.具体实例展示(tengine)

下载源码包,准备软件包

准备编译环境如编译器gcc、make
# yum -y install   gcc   make   zlib-devel  pcre  pcre-devel  openssl-devel
(pcre: 支持正则表达式,地址重写rewrite)

解压(下载在真机上的,rz上传,rz在vm虚拟机不可用,在xsheel、final shell可用)
# useradd www(用root用户的话权限太大)
# tar xvf tengine-2.2.0.tar.gz
# cd tengine-2.2.0

配置
 ./configure –prefix=/srv/nginx –with-file-aio –with-http_auth_request_module –with-http_ssl_module –with-http_v2_module –with-http_realip_module –with-http_addition_module –with-http_xslt_module=dynamic –with-http_geoip_module=dynamic –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_degradation_module –with-http_slice_module –with-http_stub_status_module –with-http_perl_module=dynamic –with-pcre –with-pcre-jit –with-stream=dynamic –with-stream_ssl_module
编译
# make

安装
# make install
二、码源安装过程错误

error1:
  the HTTP XSLT module requires the libxml2/libxslt
  libraries. You can either do not enable the module or install the libraries.

解决方案:
# yum -y install  libxml2  libxml2-dev  libxslt-devel

error2:
       perl module ExtUtils::Embed is required

解决方案:
#yum -y install perl-devel perl-ExtUtils-Embed

error3:
  the GeoIP module requires the GeoIP library.
  You can either do not enable the module or install the library.

解决方案:
# yum -y install GeoIP GeoIP-devel GeoIP-data

三、安装完成还有一堆麻烦事

1、启动测试报错

# /srv/nginx/sbin/nginx  
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

2、systemctl 查看状态

# systemctl status nginx  (restart也不行)
Unit nginx.service could not be found.

配置nginx的systemctl命令

# chmod +x /usr/lib/systemd/system/nginx.service
#vim  /usr/lib/systemd/system/nginx.service
[Unit]  //对服务的说明
Description=nginx – high performance web server    //描述服务
After=network.target remote-fs.target nss-lookup.target   //描述服务类别
[Service]        //服务的一些具体运行参数的设置
Type=forking     //后台运行的形式
PIDFile=/srv/nginx/logs/nginx.pid     //PID文件的路径
ExecStartPre=/srv/nginx/sbin/nginx -t -c /srv/nginx/conf/nginx.conf  //启动准备
ExecStart=/srv/nginx/sbin/nginx -c /srv/nginx/conf/nginx.conf   //启动命令
ExecReload=/srv/nginx/sbin/nginx -s reload  //重启命令
ExecStop=/srv/nginx/sbin/nginx -s stop  //停止命令
ExecQuit=/srv/nginx/sbin/nginx -s quit   //快速停止
PrivateTmp=true          //给服务分配临时空间
[Install]
WantedBy=multi-user.target   //服务用户的模式
4、启动服务

在启动服务之前,需要先重载systemctl命令

#systemctl daemon-reload

#systemctl start nginx.service

5、还是报错

# systemctl status nginx.service -l

nginx源码包安装

6、# ps aux|grep nginx
root      11675  0.0  0.1  46088  1156 ?        Ss   02:20   0:00 nginx: master process /srv/ngin/sbin/nginx
nobody    11676  0.0  0.2  46548  2180 ?        S    02:20   0:00 nginx: worker process
root      28181  0.0  0.0 112660   968 pts/0    R+   02:35   0:00 grep –color=auto nginx
# kill -9 11675
# kill -9 11676
# ps aux|grep nginx
root      28183  0.0  0.0 112660   964 pts/0    R+   02:35   0:00 grep –color=auto nginx
# systemctl restart nginx
# systemctl status nginx
nginx源码包安装

# /srv/nginx/sbin/nginx -v
nginx version: nginx/1.14.2
 至此大功告成

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,135
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,300