说明
-
nginx是干啥的不需要我说了吧,如果想了解的我博客中有nginx的说明,需要了解的可以在我博客中自行搜索,而且里面有说明了有外网的情况下如果通过yum来安装。 -
我这说明的呢是,内网环境安装,之前我有试过,通过下载nginx的离线安装包到内网安装,但失败了,服务依然起不来,所以后来也没折腾了,这是公司其他大佬提供的安装方法,我这重头做一遍实验,顺便整理一下笔记。 -
内网环境说明,是在云上的虚拟机上安装的,最小化安装,7.4和7.6的我之前都试过【并且有给最小化安装桌面以后再通过离线rpm安装,依然不行】 我这新建一个崭新的centos7.6的系统来通过同事提供的方法来安装【确保环境和我之前用rpn安装的环境一样】
[root@test-0321111 ~]
03:13:15 up 2 min, 2 users, load average: 0.11, 0.09, 0.04
[root@test-0321111 ~]
[root@test-0321111 ~]
CentOS Linux release 7.6.1810 (Core)
[root@test-0321111 ~]
[root@test-0321111 ~]
304
[root@test-0321111 ~]
安装过程
rpm包和tar包准备
[root@test-0321111 nginx]
/root/nginx
[root@test-0321111 nginx]
[root@test-0321111 nginx]
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]
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]
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]
[root@test-0321111 gcc]
13
[root@test-0321111 gcc]
warning: cpp-4.8.5-16.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...
Updating / installing...
1:zlib-1.2.7-17.el7
2:mpfr-3.1.1-4.el7
3:libmpc-1.0.1-3.el7
4:openssl-libs-1:1.0.2k-8.el7
5:cpp-4.8.5-16.el7
6:zlib-devel-1.2.7-17.el7
7:kernel-headers-3.10.0-693.el7
8:glibc-headers-2.17-196.el7
9:glibc-devel-2.17-196.el7
10:gcc-4.8.5-16.el7
11:openssl-devel-1:1.0.2k-8.el7
12:openssl-1:1.0.2k-8.el7
13:openssl098e-0.9.8e-29.el7.centos.
Cleaning up / removing...
14:openssl-1:1.0.2k-16.el7
15:openssl-libs-1:1.0.2k-16.el7
16:zlib-1.2.7-18.el7
[root@test-0321111 gcc]
安装gcc-c++
[root@test-0321111 gcc]
[root@test-0321111 gcc-c++]
19
[root@test-0321111 gcc-c++]
[root@test-0321111 gcc-c++]
warning: autogen-libopts-5.18-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...
Updating / installing...
1:pkgconfig-1:0.27.1-4.el7
2:zlib-1.2.7-17.el7
3:libcom_err-1.42.9-10.el7
4:openssl-libs-1:1.0.2k-8.el7
5:ntpdate-4.2.6p5-25.el7.centos.2
6:zlib-devel-1.2.7-17.el7
7:libsepol-devel-2.5-6.el7
8:libselinux-devel-2.5-11.el7
9:libverto-devel-0.2.5-4.el7
10:libstdc++-devel-4.8.5-16.el7
11:keyutils-libs-devel-1.5.8-3.el7
12:krb5-devel-1.15.1-8.el7
13:autogen-libopts-5.18-5.el7
14:ntp-4.2.6p5-25.el7.centos.2
15:openssl-devel-1:1.0.2k-8.el7
16:gcc-c++-4.8.5-16.el7
17:openssl-1:1.0.2k-8.el7
18:openssl098e-0.9.8e-29.el7.centos.
19:tcl-1:8.5.13-8.el7
Cleaning up / removing...
20:libcom_err-1.42.9-13.el7
[root@test-0321111 gcc-c++]
验证上面是否安装成功
- 执行命令
gcc -v 和g++ -v ,有内容输出即正常。
[root@test-0321111 gcc-c++]
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++]
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++]
[root@test-0321111 nginx]
/root/nginx
[root@test-0321111 nginx]
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]
pcre-8.35/
...
[root@test-0321111 nginx]
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]
[root@test-0321111 pcre-8.35]
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]
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]
[root@test-0321111 nginx]
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]
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]
[root@test-0321111 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]
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]
[root@test-0321111 nginx]
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]
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]
[root@test-0321111 nginx-1.8.1]
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[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]
[root@test-0321111 local]
nginx
[root@test-0321111 local]
3.3M nginx
[root@test-0321111 local]
配置文件说明
配置文件:/usr/local/nginx/conf/nginx.conf
[root@test-0321111 sbin]
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]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
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]
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 23341/nginx: master
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
重启nginx
- 重启nginx:
/usr/local/nginx/sbin/nginx -s reload 但我这执行这个命令好像不得行,所以重启呢,就停止在启动吧
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
[root@test-0321111 sbin]
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]
unknown
[root@test-0321111 sbin]
[root@test-0321111 sbin]
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]
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]
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]
<!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来安装。
|