zoukankan      html  css  js  c++  java
  • Nginx 的安装 与 启动

    没有图文说明,是我看着视频一步一步照做的,安装过程了,也随便把步骤记录下来了。

    我是新装 Linux 服务器,所以安装过程中出现的错误也是第一遇到,希望对你们有所帮助。

    也是方便自己以后再次安装 nignx的时候也可以看我博客了。2019-01-06

    -------------------------------------------------------------安装 nginx-------------------------------------------------------------
    进入 /usr/local/src 目录
    # cd /usr/local/src
    下载 nginx 安装包
    # wget http://nginx.org/download/nginx-1.14.2.tar.gz
    进行解压
    # tar zxvf nginx-1.14.2.tar.gz
    安装到指定目录
    # ./configure --prefix=/usr/local/nginx

    安装过程中如果出现这个错误
    ./configure: error: C compiler cc is not found
    解决方案如下
    yum -y install gcc gcc-c++ autoconf automake make
    如果出现这个错误
    ./configure: error: the HTTP rewrite module requires the PCRE library
    ...
    statically from the source with nginx by using --with-pcre=<path> option.
    解决方案 nginx 依赖于 pcre 所以我们要安装 pcre
    # yum install pcre
    # yum install pcre-devel
    如果安装过程中出现
    ./configure: error: the HTTP gzip module requires the zlib library.
    ...
    statically from the source with nginx by using --with-zlib=<path> option.
    解决方案如下
    yum install -y zlib-devel

    成功提示信息如下
    Configuration summary
    + using system PCRE library
    ...
    nginx http uwsgi temporary files: "uwsgi_temp"
    nginx http scgi temporary files: "scgi_temp"

    接下来我们就进行编译
    make && make install

    到了这里我们的nginx 也就安装成功了

    -------------------------------------------------------------启动 nginx-------------------------------------------------------------
    我们进入nginx目录下
    # cd /usr/local/nginx
    看到 四个目录
    --conf 配置文件
    --html 网页文件
    --logs 日志文件
    --sbin 进程文件

    那么我们启动就得找 进程文件 这样就启动了
    # ./sbin/nginx
    但是注意 nginx 默认端口 是80,以下信息则是80端口被占用
    nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    方案一:我们可以更改默认端口
    # cd /conf
    # vi nginx.conf
    将80 更改成你想设置的端口号就行了
    server {
    listen 80;
    下面的省略...

    方案二:关闭80端口
    查看所有端口
    # netstat -antp
    关闭80端口 对应的PID 如:17789
    # kill -9 17789

    重新启动就可以了。

    好了,就分享这么多,完成了简单的安装和启动,那么接下来的学习就靠我们自己了。

  • 相关阅读:
    弄明白python reduce 函数
    Linux 下载百度网盘大文件
    java 从网上下载文件的几种方式
    Windows下Python2与Python3两个版本共存的方法详解
    python 学习笔记
    Glide实现查看图片和保存图片到手机
    Android Animation 知识点速记备忘思维导图
    You must not call setTag() on a view Glide is targeting when use Glide
    前端数据流哲学
    精读《Optional chaining》
  • 原文地址:https://www.cnblogs.com/zhangzhonghui/p/10230752.html
Copyright © 2011-2022 走看看