CentOS 通过yum指令安装nginx

1.创建nginx安装来源

vi  /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/x86_64/
gpgcheck=0
enabled=1

  将$releasever替换为7,将$basearch替换成x86_64,这两个指令可以自动获取系统属性。

rpm -qa | grep centos-release

2.安装

yum install nginx

3.启动

service nginx start

4.本地测试是否启动服务

curl -i localhost

 

 

Ubuntu 通过apt-get安装Nginx

1.卸载默认安装

sudo apt-get remove nginx

2.安装

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:nginx/stable 
sudo apt-get update
sudo apt-get install nginx

3.启动

service nginx start

4.本地测试是否启动服务

curl -i localhost

 

 

Nginx常用指令:

Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-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/share/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

 

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!