• Centos7 安装nginx


    1、直接用yum 进行安装

    yum install nginx

     安装完成后查看nginx 的版本

    # 查看nginx版本
    nginx -v

    3、查看编译参数

    nginx -V

     4、查看安装目录

    rpm -ql nginx

    rpm -ql nginx
    /etc/logrotate.d/nginx
    /etc/nginx/fastcgi.conf
    /etc/nginx/fastcgi.conf.default
    /etc/nginx/fastcgi_params
    /etc/nginx/fastcgi_params.default
    /etc/nginx/koi-utf
    /etc/nginx/koi-win
    /etc/nginx/mime.types
    /etc/nginx/mime.types.default
    /etc/nginx/nginx.conf
    /etc/nginx/nginx.conf.default
    /etc/nginx/scgi_params
    /etc/nginx/scgi_params.default
    /etc/nginx/uwsgi_params
    /etc/nginx/uwsgi_params.default
    /etc/nginx/win-utf
    /usr/bin/nginx-upgrade
    /usr/lib/systemd/system/nginx.service
    /usr/lib64/nginx/modules
    /usr/sbin/nginx
    /usr/share/doc/nginx-1.16.1
    /usr/share/doc/nginx-1.16.1/CHANGES
    /usr/share/doc/nginx-1.16.1/README
    /usr/share/doc/nginx-1.16.1/README.dynamic
    /usr/share/doc/nginx-1.16.1/UPGRADE-NOTES-1.6-to-1.10
    /usr/share/licenses/nginx-1.16.1
    /usr/share/licenses/nginx-1.16.1/LICENSE
    /usr/share/man/man3/nginx.3pm.gz
    /usr/share/man/man8/nginx-upgrade.8.gz
    /usr/share/man/man8/nginx.8.gz
    /usr/share/nginx/html/404.html
    /usr/share/nginx/html/50x.html
    /usr/share/nginx/html/en-US
    /usr/share/nginx/html/icons
    /usr/share/nginx/html/icons/poweredby.png
    /usr/share/nginx/html/img
    /usr/share/nginx/html/index.html
    /usr/share/nginx/html/nginx-logo.png
    /usr/share/nginx/html/poweredby.png
    /usr/share/vim/vimfiles/ftdetect/nginx.vim
    /usr/share/vim/vimfiles/ftplugin/nginx.vim
    /usr/share/vim/vimfiles/indent/nginx.vim
    /usr/share/vim/vimfiles/syntax/nginx.vim
    /var/lib/nginx
    /var/lib/nginx/tmp
    /var/log/nginx
    [root@localhost conf]#

    5、修改nginx 的配置文件

     首先需要查看一下nginx 的目录结构

    [root@localhost conf]# whereis nginx


    nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/local/nginx /usr/share/nginx /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx.8.gz

     启动nginx

    cd /usr/sbin
    
    ./nginx -s reload

    如果发生如下错误

    nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
    

      

    执行以下语句

    /usr/sbin/nginx -c /etc/nginx/nginx.conf

    再次启动

    ./nginx -s reload

    确认是否启动成功

    ./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 的进程

    ps -ef|grep nginx

    添加端口到 防火墙列表

    firewall-cmd --permanent --add-port=8881/tcp
    
    #重新加载
    firewall-cmd --reload

    外部访问

    http://ip:port

     发现访问的界面与预想的不一致,差了好多资料才发现8881 是centos 系统的默认端口,所以需要换一个端口

    编辑 nginx.conf  将端口号改为8888

    执行 nginx -s reload

    再次访问

     至此nginx 安装成功。

     http://10.10.185.111:8888/niginx.cn

    如果不使用yum 安装需要注意的是不能将安装包放在 /usr/local/nginx 下否组会在make  install 时出现如下错误

    [root@localhost nginx]# make install
    make -f objs/Makefile install
    make[1]: 进入目录“/usr/local/nginx”
    test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
    test -d '/usr/local/nginx/sbin'                 || mkdir -p '/usr/local/nginx/sbin'
    test ! -f '/usr/local/nginx/sbin/nginx'                 || mv '/usr/local/nginx/sbin/nginx'                     '/usr/local/nginx/sbin/nginx.old'
    cp objs/nginx '/usr/local/nginx/sbin/nginx'
    test -d '/usr/local/nginx/conf'                 || mkdir -p '/usr/local/nginx/conf'
    cp conf/koi-win '/usr/local/nginx/conf'
    cp: "conf/koi-win" 与"/usr/local/nginx/conf/koi-win" 为同一文件
    make[1]: *** [install] 错误 1
    make[1]: 离开目录“/usr/local/nginx”
    make: *** [install] 错误 2
    

      个人的nginx 存放目录是 /home/nginx  对应的安装配置目录是/usr/local/nginx

     配置开机自启动

    vi /etc/rc.d/rc.local

    添加

    /usr/local/nginx/sbin/nginx
  • 相关阅读:
    ASP.NET AJAX__序言
    LINQ to SQL(4):OR设计器
    ASP.NET AJAX(11)__ScriptManager
    ASP.NET AJAX(15)__构建高性能ASP.NET AJAX应用
    LINQ to SQL(2):生成对象模型
    LINQ to SQL(3):增删改查
    ASP.NET AJAX(14)__UpdatePanel与服务器端脚本控件
    ASP.NET AJAX(13)__利用Microsoft AJAX Library开发客户端组件
    LINQ to SQL(1):基础入门
    ASP.NET AJAX(12)__浏览器兼容功能
  • 原文地址:https://www.cnblogs.com/ningy1009/p/12674894.html
Copyright © 2020-2023  润新知