安装
第一种安装方式:CentOS 7下配置 yum 安装 Nginx。
按照官方的安装实例:https://www.nginx.com/resources/admin-guide/
第一步,在/etc/yum.repos.d/目录下创建一个源配置文件nginx.repo
cd /etc/yum.repos.d/

vim nginx.repo

填写如下内容:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=
enabled=

保存,则会产生一个/etc/yum.repos.d/nginx.repo文件。

下面直接执行如下指令即可自动安装好Nginx:

yum install nginx -y

第二种:在各平台上直接执行对应安装命令

# CentOS
yum install nginx;
# Ubuntu
sudo apt-get install nginx;
# Mac
brew install nginx;

启动

接下来看一下nginx的安装路径:

[root@localhost ~]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx..gz
[root@localhost ~]#

cd切换到 /usr/sbin/nginx,使用./nginx启动nginx

如果出现:nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

多半是80端口被占用,可以通过修改nginx启动的配置文件来修改,配置文件地址:/etc/nginx/nginx.conf

正常的话,用 ps -ef|grep nginx 应该可以看到2个进程:

[root@localhost ~]#  ps -ef|grep nginx
root 3月26 ? :: nginx: master process ./nginx
nginx 3月26 ? :: nginx: worker process

表示启动正常,可以使用curl http://localhost 查看nginx输出内容,或者是通过浏览器来查看nginx欢迎界面

其它一些有用的启动参数:

Usage: nginx [-?hvVtq] [-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
-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/Cellar/nginx/1.8./)
-c filename : set configuration file (default: /usr/local/etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file

特别要提一下-V(大写),有时候不知道配置文件在哪,用这个参数就能查出来。

[root@localhost ~]# nginx -V
nginx version: nginx/1.10.
built by gcc 4.8. (Red Hat 4.8.-) (GCC)
built with OpenSSL 1.0.1e-fips Feb
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-file-aio --with-threads --with-ipv6 --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

从输出内容可以看出里面包含了nginx启动的文件,启动的配置文件,以及一些其他的参数

也可以通过nginx -t来检查配置文件是否正确

卸载、停止服务

卸载只要把目录删除掉就行了,如果自己为了运维方便,做了其它启动的脚本,同步删除停止服务,直接kill掉nginx进程最直接。

当然也可以 ./nginx -s stop

Nginx 安装与启动的更多相关文章

  1. 002.Nginx安装及启动

    一 Nginx yum安装 1.1 前置准备 1 [root@nginx01 ~]# systemctl status firewalld.service #检查防火墙 2 [root@nginx01 ...

  2. nginx 安装、启动、重启、关闭 (linux系统命令行)

    前言: 最近在部署我的hexo静态博客到腾讯云服务器上,用到了很多nginx的知识,在此做下总结: 刚接触的linux服务器上,nginx配置乱的有点令人发指,就把老的卸载了重新装一下. 1.卸载 y ...

  3. Nginx - 安装并启动Nginx

    1 - 安装Nginx 官网步骤:http://nginx.org/en/linux_packages.html#RHEL-CentOS [Anliven@h202 ~]$ sudo vim /etc ...

  4. (Nginx学习一)安装和启动及对应文件夹介绍

    nginx 安装和启动及对应文件夹介绍 1 安装 官网下载nginx文件  http://nginx.org/en/download.html 解压即可 2 文件夹介绍 在解压后nginx压缩包后发现 ...

  5. Nginx下载和安装与启动

    nginx是什么 nginx是一个开源的,支持高性能,高并发的www服务和代理服务软件.它是一个俄罗斯人lgor sysoev开发的,作者将源代码开源出来供全球使用. nginx比它大哥apache性 ...

  6. CentOS7.3编译安装Nginx设置开机启动

    起因 最近想玩nginx了,本来用yum -y install nginx安装也启动好了,但是买了本<Nginx高性能Web服务器详解>,我咋能辜负我的书费呢?于是我就直接ps -ef | ...

  7. VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)

    首先启动Nginx 1. 相关浏览 两个 Tomcat 配置:  VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...

  8. linux下安装nginx后开机启动篇

    众所周知nginx安装后需要手动去启动,每次开机之后都要执行nginx的启动命令很蛋疼.那么我们来让nginx开机启动吧 1.先創建一個nginx文件把 [root@localhost ~]# vi ...

  9. Windows 安装nginx并开机启动

    Win安装nginx并 开机启动 下载nginx安装包 nginx-1.12.2.zip,解压到D盘. https://pan.baidu.com/s/1InQa527yq35Q68c73RBb-A# ...

随机推荐

  1. 解决office2007-安装程序找不到office.zh-cn\Setup.xml

    安装Microsoft Office Project Standard 2007时出现了小问题,经过百度google一番后才发现安装office2007与安装vs2008有着紧密的联系,参见:http ...

  2. 【IntellJ IDEA】idea上所有代码都报错了

    可能会碰到蓝屏,内存溢出重启idea等特殊情况. 重新打开idea后发现原本的代码全都报错了 正确的解决方法: 方法很简单 执行idea工具栏上下面的菜单: File -> Invalidate ...

  3. Appium+python自动化19-iOS模拟器(iOS Simulator)安装自家APP

    前言 做过iOS上app测试的小伙伴应该都知道,普通用户安装app都是从appstore下载安装,安装测试版本的app,一般就是开发给的二维码扫码安装, 或者开发给个.ipa的安装包文件,通过itoo ...

  4. [Linux] Ubuntu下解压rar文件的方法

    一般通过默认安装的ubuntu是不能解压rar文件的,只有在安装了rar解压工具之后,才可以解压.其实在ubuntu下安装rar解压工具是非常简单的,只需要两个步骤就可以迅速搞定. ubuntu 下r ...

  5. sqlserver 汉字转拼音

    作者不详       --方法一sqlserver汉字转拼音首字母 --调用方法 select dbo.procGetPY ('中國') Create FUNCTION dbo.procGetPY ( ...

  6. 关于FFmpegInterop项目的编译

    如果是从git 上下载的最新版本 FFmpeg,那么打开VS2015编译时会报出一个错误    C4996    'av_free_packet': 被声明为已否决    FFmpegInterop  ...

  7. solr入门之參考淘宝搜索提示功能优化拼音加汉字搜索功能

    首先看一下从淘宝输入搜索keyword获取到的一些数据信息: 第一张:使用拼音的全程来查询 能够看到提示的是匹配的转换的拼音的方式,看最后一个提示项 这里另一个在指定分类文件夹下搜索的功能,难道后台还 ...

  8. 从头认识java-13.11 对照数组与泛型容器,观察类型擦除给泛型容器带来什么问题?

    这一章节我们继续类型擦除的话题,我们将通过对照数组与泛型容器,观察类型擦除给泛型容器带来什么问题? 1.数组 package com.ray.ch13; public class Test { pub ...

  9. Scheme 4 Javaer-3.高阶函数

    1.3  Formulating Abstractions with Higher-Order Procedures 教材有时候依照学生的基础.从0讲起:有时候给出一个大图,然后具体地逐一介绍. 本文 ...

  10. SVN 快速入门!

    输入账户密码即可!