首页 > 系统相关 >Linux安装Nginx - Linux

Linux安装Nginx - Linux

时间:2022-11-04 18:36:49浏览次数:63  
标签:http nginx -- local module Nginx conf Linux 安装


文章目录

  • ​​一. Nginx安装​​
  • ​​二. nginx其他相关命令​​
  • ​​三. 外网访问​​

一. Nginx安装


官网下载Nginx: ​​https://nginx.org/en/download.html​

Linux安装Nginx - Linux_运维


下载后, 将压缩包放到Linux系统中.

可以使用xftp工具或者rz命令

然后就是解压,安装

# 解压
$ tar -zvxf nginx-1.18.0.tar.gz

$ cd nginx-1.18.0

$ ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module

# 编译安装
$ make&&make install

检验是否安装成功

$cd /usr/local/nginx/sbin

$ ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

如果报这个错误: nginx: [emerg] getpwnam("nginx") failed in /usr/local/nginx/conf/nginx.conf​​
解决方法:
编辑​​​/usr/local/nginx/conf/nginx.conf​​​这个文件, 将​​user nobody​​这个注释去掉.

Linux安装Nginx - Linux_nginx_02


参考: ​

​nginx重启报错: [emerg] getpwnam(“www”) failed…​

二. nginx其他相关命令


# 启动
$ ./nginx
# 停止
$ ./nginx -s stop
# 重新启动
$ ./nginx -s reload

# 查看nginx是否启动成功
$ ps -ef|grep nginx

启动时, 首先要确保系统的80端口是否占用

# 查看端口是否占用$ netstat -ano|grep 80

如果占用则需要到​​/usr/local/nginx/conf/nginx.conf​​文件中修改启动端口.

Linux安装Nginx - Linux_nginx安装_03

三. 外网访问


访问地址就是服务器IP:端口号
访问失败的话, 检查端口是否设置防火墙

# 对外开放访问的端口
$ firewall-cmd --add-port=端口号/tcp --permanent
# 重新加载防火墙设置
$ firewall-cmd --reload

# 查看已经开放的端口号
$ firewall-cmd --list-all

参考文章:


标签:http,nginx,--,local,module,Nginx,conf,Linux,安装
From: https://blog.51cto.com/u_14233037/5824462

相关文章

  • linux 中输出参考基因组gff文件第9列的注释类别
     001、[root@pc1test3]#lsGCF_000001405.40_GRCh38.p14_genomic.gff[root@pc1test3]#awk'$3=="gene"{split($9,a,";");for(iina){split(a[i],b,"=")......
  • Vue项目或Django项目在Linux系统持续运行 - XShell
    Vue项目$nohupnpmrunserve&exitDjango项目$nohuppythonmanage.pyrunserver0.0.0.0:8000>nohup.out&exit稍微解释一下命令:nohup:不挂断的运行命令>nohup.out:......
  • Linux安装nodejs
    nodejs下载官方地址:​​https://nodejs.org/zh-cn/download/​​Linux查看当前系统位数:​​getconfLONG_BIT​​官网上下载好二进制文件后,可以通过​​xftp工具​​​......
  • Linux安装Anaconda
    一、Linux安装AnacondaAnaconda官方下载地址:​​https://www.anaconda.com/products/individual#​​Linux运行$bashAnaconda3-2020.02-Linux-x86_64.sh#一路Enter#出现......
  • linux 中 awk命令中数组的应用
     001、基本用法[root@pc1test4]#lsa.txt[root@pc1test4]#cata.txtabcdbeadezbcade[root@pc1test4]#awk'{printay[$2]++}'a.txt01021......
  • remix安装以及链接链
    环境Ubuntu安装remix-idedockerrun-d-p8881:80remixproject/remix-ide:OktoOK成功如下浏览器访问http://localhost:8881链接Environment->web3Provide......
  • xgboost安装踩坑
     win10系统安装xgboost确实坑多,最初直接安装python3.7和pycharm的方式一直未成功,后面想着使用anaconda来进行相关python包管理。    踩坑步骤如下:   1.使用ana......
  • linux 文件打包 / 分割 / 组合 / 解压
    较多时候我们在linux下使用tar打包文件夹,会出现打包后的文件过大,在文件copy过程中需要切片成较小文件。步骤:1.先压缩,然后切片**打包命令:#tarzcvfimages.tar.......
  • orchestrator安装部署(raft版本)
    环境OS:Centos7mysql(5.7)主从:192.168.1.100hmaster主192.168.1.102hslavea从192.168.1.103hslaveb从192.168.1.104orchestrator元数据使用的数据库 前提条件......
  • mac linux 查看端口占用情况
    maclsof-i:8080nodejs项目,启动初问题了,终断后,老出现,端口占用启动不了的情况linux1.也可以用lsof-i:端口号----发现有的linux服务器不支持lsofnetstat-ntl......