美文网首页
linux 安装nginx

linux 安装nginx

作者: 夜空最亮的9星 | 来源:发表于2022-05-08 07:45 被阅读0次

安装依赖

yum -y install pcre pcre-devel

yum -y install openssl openssl-devel


编译安装

[root@VM-16-15-centos ~]# cd /opt/nginx-1.21.6/

 [root@VM-16-15-centos ~]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module
 
[root@VM-16-15-centos ~]# make && make install

创建软连接

ln -s /opt/nginx/sbin/nginx  /usr/sbin/

启动

[root@VM-16-15-centos conf]# nginx

参数 -c 指定配置文件的路径
如果不加 "-c" 参数,Nginx 会默认加载其安装目录的 conf子目录中的 nginx.conf 文件

测试是否启动成功

lsof–i :80或netstat –tunpl |grep80;

查看帮助

[root@VM-16-15-centos ~]# nginx -h
nginx version: nginx/1.21.6
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
             [-e filename] [-c filename] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/nginx/)
  -e filename   : set error log file (default: logs/error.log)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file

使用

<!--停止nginx的服务-->
[root@VM-16-15-centos ~]# nginx –s stop 

<!--不停止nginx的服务,重新加载配置文件-->
[root@VM-16-15-centos ~]# nginx –s reload 

<!--测试配置文件是否正确:-->

[root@VM-16-15-centos ~]# 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
[root@VM-16-15-centos ~]# 

相关文章

网友评论

      本文标题:linux 安装nginx

      本文链接:https://www.haomeiwen.com/subject/khgfurtx.html