IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> 内网环境安装nginx【由rpm包+tar包完成】、tar包安装的nginx服务启动停止重启和查看状态 -> 正文阅读

[系统运维]内网环境安装nginx【由rpm包+tar包完成】、tar包安装的nginx服务启动停止重启和查看状态

说明

  • nginx是干啥的不需要我说了吧,如果想了解的我博客中有nginx的说明,需要了解的可以在我博客中自行搜索,而且里面有说明了有外网的情况下如果通过yum来安装。

  • 我这说明的呢是,内网环境安装,之前我有试过,通过下载nginx的离线安装包到内网安装,但失败了,服务依然起不来,所以后来也没折腾了,这是公司其他大佬提供的安装方法,我这重头做一遍实验,顺便整理一下笔记。

  • 内网环境说明,是在云上的虚拟机上安装的,最小化安装,7.4和7.6的我之前都试过【并且有给最小化安装桌面以后再通过离线rpm安装,依然不行】
    我这新建一个崭新的centos7.6的系统来通过同事提供的方法来安装【确保环境和我之前用rpn安装的环境一样】
    在这里插入图片描述

[root@test-0321111 ~]# uptime 
 03:13:15 up 2 min,  2 users,  load average: 0.11, 0.09, 0.04
[root@test-0321111 ~]# 

[root@test-0321111 ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@test-0321111 ~]# 
[root@test-0321111 ~]# rpm -qa|wc -l
304
[root@test-0321111 ~]# 

安装过程

rpm包和tar包准备

[root@test-0321111 nginx]# pwd
/root/nginx
[root@test-0321111 nginx]# 
[root@test-0321111 nginx]# ls
gcc  gcc-c++  libtool-2.4.2.tar.gz  nginx-1.8.1.tar.gz  pcre-8.35.tar.gz
[root@test-0321111 nginx]# 
[root@test-0321111 nginx]# ls gcc
cpp-4.8.5-16.el7.x86_64.rpm          glibc-headers-2.17-196.el7.x86_64.rpm     mpfr-3.1.1-4.el7.x86_64.rpm                    openssl-devel-1.0.2k-8.el7.x86_64.rpm  zlib-devel-1.2.7-17.el7.x86_64.rpm
gcc-4.8.5-16.el7.x86_64.rpm          kernel-headers-3.10.0-693.el7.x86_64.rpm  openssl098e-0.9.8e-29.el7.centos.3.x86_64.rpm  openssl-libs-1.0.2k-8.el7.x86_64.rpm
glibc-devel-2.17-196.el7.x86_64.rpm  libmpc-1.0.1-3.el7.x86_64.rpm             openssl-1.0.2k-8.el7.x86_64.rpm                zlib-1.2.7-17.el7.x86_64.rpm
[root@test-0321111 nginx]# 
[root@test-0321111 nginx]# ls gcc-c++/
autogen-libopts-5.18-5.el7.x86_64.rpm       libcom_err-1.42.9-10.el7.x86_64.rpm      libverto-devel-0.2.5-4.el7.x86_64.rpm          openssl-1.0.2k-8.el7.x86_64.rpm        tcl-8.5.13-8.el7.x86_64.rpm
gcc-c++-4.8.5-16.el7.x86_64.rpm             libselinux-devel-2.5-11.el7.x86_64.rpm   ntp-4.2.6p5-25.el7.centos.2.x86_64.rpm         openssl-devel-1.0.2k-8.el7.x86_64.rpm  zlib-1.2.7-17.el7.x86_64.rpm
keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm  libsepol-devel-2.5-6.el7.x86_64.rpm      ntpdate-4.2.6p5-25.el7.centos.2.x86_64.rpm     openssl-libs-1.0.2k-8.el7.x86_64.rpm   zlib-devel-1.2.7-17.el7.x86_64.rpm
krb5-devel-1.15.1-8.el7.x86_64.rpm          libstdc++-devel-4.8.5-16.el7.x86_64.rpm  openssl098e-0.9.8e-29.el7.centos.3.x86_64.rpm  pkgconfig-0.27.1-4.el7.x86_64.rpm
[root@test-0321111 nginx]# 

安装gcc

  • 看过程,有问题留言。
[root@test-0321111 nginx]# cd gcc
[root@test-0321111 gcc]# ls | wc -l
13
[root@test-0321111 gcc]# rpm -ivhU * --nodeps --force
warning: cpp-4.8.5-16.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zlib-1.2.7-17.el7                ################################# [  6%]
   2:mpfr-3.1.1-4.el7                 ################################# [ 13%]
   3:libmpc-1.0.1-3.el7               ################################# [ 19%]
   4:openssl-libs-1:1.0.2k-8.el7      ################################# [ 25%]
   5:cpp-4.8.5-16.el7                 ################################# [ 31%]
   6:zlib-devel-1.2.7-17.el7          ################################# [ 38%]
   7:kernel-headers-3.10.0-693.el7    ################################# [ 44%]
   8:glibc-headers-2.17-196.el7       ################################# [ 50%]
   9:glibc-devel-2.17-196.el7         ################################# [ 56%]
  10:gcc-4.8.5-16.el7                 ################################# [ 63%]
  11:openssl-devel-1:1.0.2k-8.el7     ################################# [ 69%]
  12:openssl-1:1.0.2k-8.el7           ################################# [ 75%]
  13:openssl098e-0.9.8e-29.el7.centos.################################# [ 81%]
Cleaning up / removing...
  14:openssl-1:1.0.2k-16.el7          ################################# [ 88%]
  15:openssl-libs-1:1.0.2k-16.el7     ################################# [ 94%]
  16:zlib-1.2.7-18.el7                ################################# [100%]
[root@test-0321111 gcc]# 

安装gcc-c++

  • 看过程,有问题留言。
[root@test-0321111 gcc]# cd ../gcc-c++/
[root@test-0321111 gcc-c++]# ls | wc -l
19
[root@test-0321111 gcc-c++]# 
[root@test-0321111 gcc-c++]# rpm -ivhU * --nodeps --force
warning: autogen-libopts-5.18-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:pkgconfig-1:0.27.1-4.el7         ################################# [  5%]
   2:zlib-1.2.7-17.el7                ################################# [ 10%]
   3:libcom_err-1.42.9-10.el7         ################################# [ 15%]
   4:openssl-libs-1:1.0.2k-8.el7      ################################# [ 20%]
   5:ntpdate-4.2.6p5-25.el7.centos.2  ################################# [ 25%]
   6:zlib-devel-1.2.7-17.el7          ################################# [ 30%]
   7:libsepol-devel-2.5-6.el7         ################################# [ 35%]
   8:libselinux-devel-2.5-11.el7      ################################# [ 40%]
   9:libverto-devel-0.2.5-4.el7       ################################# [ 45%]
  10:libstdc++-devel-4.8.5-16.el7     ################################# [ 50%]
  11:keyutils-libs-devel-1.5.8-3.el7  ################################# [ 55%]
  12:krb5-devel-1.15.1-8.el7          ################################# [ 60%]
  13:autogen-libopts-5.18-5.el7       ################################# [ 65%]
  14:ntp-4.2.6p5-25.el7.centos.2      ################################# [ 70%]
  15:openssl-devel-1:1.0.2k-8.el7     ################################# [ 75%]
  16:gcc-c++-4.8.5-16.el7             ################################# [ 80%]
  17:openssl-1:1.0.2k-8.el7           ################################# [ 85%]
  18:openssl098e-0.9.8e-29.el7.centos.################################# [ 90%]
  19:tcl-1:8.5.13-8.el7               ################################# [ 95%]
Cleaning up / removing...
  20:libcom_err-1.42.9-13.el7         ################################# [100%]
[root@test-0321111 gcc-c++]# 

验证上面是否安装成功

  • 执行命令gcc -vg++ -v,有内容输出即正常。
[root@test-0321111 gcc-c++]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
[root@test-0321111 gcc-c++]# 
[root@test-0321111 gcc-c++]# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
[root@test-0321111 gcc-c++]# 

安装PCRE

回到pcre的tar包所在路径

[root@test-0321111 gcc-c++]# cd ..
[root@test-0321111 nginx]# pwd
/root/nginx
[root@test-0321111 nginx]# ls
gcc  gcc-c++  libtool-2.4.2.tar.gz  nginx-1.8.1.tar.gz  pcre-8.35.tar.gz
[root@test-0321111 nginx]# 

解压

tar -zxvf pcre-8.35.tar.gz

[root@test-0321111 nginx]# tar -zxvf pcre-8.35.tar.gz
pcre-8.35/
...
[root@test-0321111 nginx]# ls
gcc  gcc-c++  libtool-2.4.2.tar.gz  nginx-1.8.1.tar.gz  pcre-8.35  pcre-8.35.tar.gz
[root@test-0321111 nginx]# 

配置,环境检查

cd pcre-8.35./configure

[root@test-0321111 nginx]# cd pcre-8.35
[root@test-0321111 pcre-8.35]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
。。。
config.status: creating pcre_stringpiece.h
config.status: creating pcrecpparg.h
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing script-chmod commands
config.status: executing delete-old-chartables commands

pcre-8.35 configuration summary:

    Install prefix .................. : /usr/local
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ : 
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... : 
    Extra libraries ................. : 

    Build 8 bit pcre library ........ : yes
    Build 16 bit pcre library ....... : no
    Build 32 bit pcre library ....... : no
    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8/16/32 support ...... : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    EBCDIC code for NL .............. : n/a
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Nested parentheses limit ........ : 250
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no

[root@test-0321111 pcre-8.35]# 

编译并安装

make && make install

[root@test-0321111 pcre-8.35]# make && make install
rm -f pcre_chartables.c
ln -s ./pcre_chartables.c.dist pcre_chartables.c
make  all-am
make[1]: Entering directory `/root/nginx/pcre-8.35'
  CC       libpcre_la-pcre_byte_order.lo
  CC       libpcre_la-pcre_compile.lo
  CC       libpcre_la-pcre_config.lo
  CC       libpcre_la-pcre_dfa_exec.lo
  CC       libpcre_la-pcre_exec.lo
  CC       libpcre_la-pcre_fullinfo.lo
  CC       libpcre_la-pcre_get.lo
  CC       libpcre_la-pcre_globals.lo
  CC       libpcre_la-pcre_jit_compile.lo
  CC       libpcre_la-pcre_maketables.lo
  CC       libpcre_la-pcre_newline.lo
  CC       libpcre_la-pcre_ord2utf8.lo
  CC       libpcre_la-pcre_refcount.lo
  CC       libpcre_la-pcre_string_utils.lo
  CC       libpcre_la-pcre_study.lo
  CC       libpcre_la-pcre_tables.lo
  CC       libpcre_la-pcre_ucd.lo
  CC       libpcre_la-pcre_valid_utf8.lo
  CC       libpcre_la-pcre_version.lo
  CC       libpcre_la-pcre_xclass.lo
  CC       libpcre_la-pcre_chartables.lo
  CCLD     libpcre.la
  CC       libpcreposix_la-pcreposix.lo
  CCLD     libpcreposix.la
  CXX      libpcrecpp_la-pcrecpp.lo
  CXX      libpcrecpp_la-pcre_scanner.lo
  CXX      libpcrecpp_la-pcre_stringpiece.lo
  CXXLD    libpcrecpp.la
  CC       pcretest-pcretest.o
  CC       pcretest-pcre_printint.o
  CCLD     pcretest
  CC       pcregrep-pcregrep.o
  CCLD     pcregrep
  CXX      pcrecpp_unittest-pcrecpp_unittest.o
  CXXLD    pcrecpp_unittest
  CXX      pcre_scanner_unittest-pcre_scanner_unittest.o
  CXXLD    pcre_scanner_unittest
  CXX      pcre_stringpiece_unittest-pcre_stringpiece_unittest.o
  CXXLD    pcre_stringpiece_unittest
make[1]: Leaving directory `/root/nginx/pcre-8.35'
...
/usr/local/share/man/man3/pcre32_utf32_to_host_byte_order.3
ln -sf pcre_version.3                    /usr/local/share/man/man3/pcre32_version.3
make[3]: Leaving directory `/root/nginx/pcre-8.35'
make[2]: Leaving directory `/root/nginx/pcre-8.35'
make[1]: Leaving directory `/root/nginx/pcre-8.35'
[root@test-0321111 pcre-8.35]# 

安装libtool

回到libtool的tar包所在路径

[root@test-0321111 pcre-8.35]# cd ..
[root@test-0321111 nginx]# ls
gcc  gcc-c++  libtool-2.4.2.tar.gz  nginx-1.8.1.tar.gz  pcre-8.35  pcre-8.35.tar.gz
[root@test-0321111 nginx]# 

解压

tar -zxvf libtool-2.4.2.tar.gz

[root@test-0321111 nginx]# tar -zxvf libtool-2.4.2.tar.gz
libtool-2.4.2/
。。。
libtool-2.4.2/doc/notes.txt
libtool-2.4.2/doc/PLATFORMS
libtool-2.4.2/doc/stamp-vti
libtool-2.4.2/doc/version.texi
[root@test-0321111 nginx]# 

配置,环境检查

cd libtool-2.4.2./configure

[root@test-0321111 nginx]# cd libtool-2.4.2
[root@test-0321111 libtool-2.4.2]# ./configure
## ------------------------- ##
## Configuring libtool 2.4.2 ##
## ------------------------- ##

checking for a BSD-compatible install... /usr/bin/install -c
...
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... no
checking for g95... no
checking for xlf95... no
checking for f95... no
checking for fort... no
checking for ifort... no
checking for ifc... no
checking for efc... no
checking for pgfortran... no
checking for pgf95... no
checking for lf95... no
checking for ftn... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether  accepts -g... no
checking for gfortran... no
checking for g95... no
checking for xlf95... no
checking for f95... no
checking for fort... no
checking for ifort... no
checking for ifc... no
checking for efc... no
checking for pgfortran... no
checking for pgf95... no
checking for lf95... no
checking for ftn... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking whether we are using the GNU Fortran compiler... no
checking whether  accepts -g... no
checking for gccgo... no
checking for gcj... no
checking for windres... no
checking whether make supports order-only prerequisites... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing tests/atconfig commands
config.status: executing depfiles commands
config.status: executing libtool commands
[root@test-0321111 libtool-2.4.2]# 

编译并安装

make && make install

[root@test-0321111 libtool-2.4.2]# make && make install
rm -f libtoolize.tmp libtoolize
sed -e 's,@aclocal_DATA\@,m4/argz.m4 m4/libtool.m4 m4/ltdl.m4 m4/ltoptions.m4 m4/ltsugar.m4 
...
test -z "/usr/local/share/man/man1" || /usr/bin/mkdir -p "/usr/local/share/man/man1"
 /usr/bin/install -c -m 644 ./doc/libtool.1 ./doc/libtoolize.1 '/usr/local/share/man/man1'
make[3]: Leaving directory `/root/nginx/libtool-2.4.2'
make[2]: Leaving directory `/root/nginx/libtool-2.4.2'
make[1]: Leaving directory `/root/nginx/libtool-2.4.2'
[root@test-0321111 libtool-2.4.2]# 

安装nginx

回到nginx的tar包所在路径

[root@test-0321111 libtool-2.4.2]# cd ..
[root@test-0321111 nginx]# ls
gcc  gcc-c++  libtool-2.4.2  libtool-2.4.2.tar.gz  nginx-1.8.1.tar.gz  pcre-8.35  pcre-8.35.tar.gz
[root@test-0321111 nginx]# 

解压

tar -zxvf nginx-1.8.1.tar.gz

[root@test-0321111 nginx]# tar -zxvf nginx-1.8.1.tar.gz
nginx-1.8.1/
。。。
nginx-1.8.1/auto/cc/msvc
nginx-1.8.1/auto/cc/name
nginx-1.8.1/auto/cc/owc
nginx-1.8.1/auto/cc/sunc
[root@test-0321111 nginx]# 

配置,环境检查

cd libtool-2.4.2./configure

[root@test-0321111 nginx]# cd nginx-1.8.1
[root@test-0321111 nginx-1.8.1]# ./configure
checking for OS
...
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

[root@test-0321111 nginx-1.8.1]# 

编译并安装

make && make install

[root@test-0321111 nginx-1.8.1]# make && make install
...
make[1]: Entering directory `/root/nginx/nginx-1.8.1'
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
        -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
        -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
        -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
        < man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/root/nginx/nginx-1.8.1'
make -f objs/Makefile install
make[1]: Entering directory `/root/nginx/nginx-1.8.1'
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-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types'              || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params'          || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params          '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf'            || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params'            || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params            '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params'             || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params             '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf'              || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs'                 || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' ||              mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html'                 || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' ||              mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/nginx/nginx-1.8.1'

常用命令【必看】

  • 这种方式安装的启动方式不是用systemctl的,看下面。

启动nginx

  • 启动nginx : nginx安装目录地址 -c nginx配置文件地址
  • 安装后的路径好像会被变到/usr/local 里面确认一下
[root@test-0321111 nginx-1.8.1]# cd /usr/local/
[root@test-0321111 local]# ls | grep nginx
nginx
[root@test-0321111 local]# du -sh nginx
3.3M    nginx
[root@test-0321111 local]# 

配置文件说明

配置文件:/usr/local/nginx/conf/nginx.conf

[root@test-0321111 sbin]# cat /usr/local/nginx/conf/nginx.conf | egrep -v '#'

worker_processes  1;




events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;



    sendfile        on;

    keepalive_timeout  65;


    server {
        listen       80;
        server_name  localhost;



        location / {
            root   html;
            index  index.html index.htm;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }



    }










}
[root@test-0321111 sbin]# 

启动nginx

  • 启动nginx:cd /usr/local/nginx/sbin && ./nginx
    其实重启的话呢,可以停止nginx,在启动ngixn。
[root@test-0321111 nginx]# cd /usr/local/nginx/sbin/
[root@test-0321111 sbin]# ./nginx 
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# netstat -tunlp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      23341/nginx: master 
[root@test-0321111 sbin]# 

停止nginx

  • 停止nginx:/usr/local/nginx/sbin/nginx -s stop (quit)
[root@test-0321111 sbin]# netstat -tunlp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      23341/nginx: master 
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# /usr/local/nginx/sbin/nginx -s stop
[root@test-0321111 sbin]# netstat -tunlp | grep 80
[root@test-0321111 sbin]# 

重启nginx

  • 重启nginx:/usr/local/nginx/sbin/nginx -s reload
    但我这执行这个命令好像不得行,所以重启呢,就停止在启动吧
[root@test-0321111 sbin]# netstat -tunlp | grep 80
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# /usr/local/nginx/sbin/nginx -s reload
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# netstat -tunlp | grep 80
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# ./nginx 
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# netstat -tunlp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      23360/nginx: master 
[root@test-0321111 sbin]# 

查看nginx端口或者状态

  • 我前面说过,tar包安装的方式呢,使用方法和rpm安装的不一样,所以状态查看也一样,我们不能通过systemctl来查看,如下,状态是unknown,但nginx端口是没问题的
[root@test-0321111 sbin]# systemctl is-active nginx
unknown
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# netstat -tunlp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      23360/nginx: master 
[root@test-0321111 sbin]# 
  • 所以正确方式呢,我们查看nginx状态是通过ps看进程,和看端口情况,如果端口在肯定没问题。
    • 1、查看ngix是否启动:ps -ef | grep nginx
    • 2、查看nginx的端口
[root@test-0321111 sbin]# ps -ef | grep nginx
root     23360     1  0 03:51 ?        00:00:00 nginx: master process ./nginx
nobody   23361 23360  0 03:51 ?        00:00:00 nginx: worker process
root     23367 12582  0 03:55 pts/0    00:00:00 grep --color=auto nginx
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# 
[root@test-0321111 sbin]# netstat -tunlp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      23360/nginx: master 
[root@test-0321111 sbin]# 

测试

  • nginx的配置文件为安装目录下的nginx目录中的nginx.conf,默认端口为80,启动后出现如下页面即为启动成功
[root@test-0321111 sbin]# curl 10.241.103.206
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@test-0321111 sbin]# 
  • 浏览器中也可以看到的

在这里插入图片描述

  • 使用呢,我这就不做说明了,如果想了解的我博客中有nginx的说明,需要了解的可以在我博客中自行搜索,而且里面有说明了有外网的情况下如果通过yum来安装。
  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2022-03-22 21:01:04  更:2022-03-22 21:05:08 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/15 23:27:24-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码