nginx(一):nginx的安装配置和启动

去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 422 11:23 conf
drwxr-xr-x. 2 root root   40 422 11:23 html
drwxr-xr-x. 2 root root    6 422 11:23 logs
drwxr-xr-x. 2 root root   19 422 11:23 sbin
[root@localhost nginx]# cd sbin
[root@localhost sbin]# ll
总用量 5972
-rwxr-xr-x. 1 root root 6114128 422 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值