去nginx官网 nginx.org,安装nginx1.26.0
一 安装nginx安装包
将nginx安装包nginx-1.23.3.tar.gz 移到这个目录里面/var/tmp/
然后解压tar -xvf nginx-1.23.3.tar.gz
二 安装相应的依赖配置文件
源码安装需要先安装依赖,官方文档有相关的依赖包说明
configure,配置一些路径,第三方模块
[root@localhost tmp]# cd nginx-1.23.3
[root@localhost nginx-1.23.3]# ./configure \
> --prefix=/usr/local/nginx \
> --sbin-path=/usr/local/nginx/sbin/nginx \
> --conf-path=/usr/local/nginx/conf/nginx.conf \
> --error-log-path=/usr/local/nginx/logs/error.log \
> --http-log-path=/usr/local/nginx/logs/access.log \
> --pid-path=/usr/local/nginx/logs/nginx.pid \
> --with-http_stub_status_module \
> --with-http_ssl_module \
> --with-http_gzip_static_module \
> --with-pcre
configure里面参数的含义:
–prefix 指定Nginx程序的安装路径
–sbin-path 设置Nginx二进制文件的路径名
–conf-path 指定Nginx配置文件路径
–error-log-path 指定Nginx错误日志文件路径
–http-log-path 指定Nginx访问日志文件路径
–pid-path 设置Nginx的pid文件nginx.pid的路径
–lock-path 设置Nginx的lock文件nginx.lock文件路径
–with-openssl 指定OpenSSL源码包的路径,如果编译的时候没有指定“–with-openssl”选项,那么默认会使‘
用系统自带的openssl库
–with-pcre 设置Nginx启用正则表达式
–with-http_stub_status_module 安装用来监控Nginx状态的模块
–with-http_ssl_module 表示启用Nginx的SSL模块,此模块依赖“–with-openssl”这个选项,通常一起使用。
–with-http_gzip_static_module 表示启用Nginx的gzip压缩
之后编译安装
make && make install
这个编译的时间会比较长
先编译,后安装
三 去安装目录下
默认启动80端口
[root@localhost nginx-1.23.3]# cd /usr/local/nginx/
[root@localhost nginx]# ll
总用量 4
drwxr-xr-x. 2 root root 4096 4月 22 11:23 conf
drwxr-xr-x. 2 root root 40 4月 22 11:23 html
drwxr-xr-x. 2 root root 6 4月 22 11:23 logs
drwxr-xr-x. 2 root root 19 4月 22 11:23 sbin
[root@localhost nginx]# cd sbin
[root@localhost sbin]# ll
总用量 5972
-rwxr-xr-x. 1 root root 6114128 4月 22 11:23 nginx
[root@localhost sbin]# ./nginx
[root@localhost sbin]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports: 9090/tcp 3000/tcp 9091/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@localhost sbin]# firewall-cmd --add-port=80/tcp --permanent
success
[root@localhost sbin]# firewall-cmd --reload
success