不指定参数配置的Nginx编译安装

./configure
make
make install
wget下载或浏览器下载上传。解压进入目录
[root@mcw1 nginx-1.10.2]# ls #查看文件
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@mcw1 nginx-1.10.2]# file configure #这是个 shell脚本
configure: POSIX shell script, ASCII text executable
[root@mcw1 nginx-1.10.2]# ./configure #直接执行,会先做检查,查到没有的库,报错
checking for OS
+ Linux 3.10.0-693.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
.........
checking for PCRE library in /usr/include/pcre/ ... not found #它是去各处找了
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
[root@mcw1 nginx-1.10.2]# yum install pcre pcre-devel -y #缺少依赖,安装依赖
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
epel/x86_64/primary_db | 7.0 MB 00:00:00
Package pcre-8.32-17.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
Package Arch Version Repository Size
============================================================================================
Installing:
pcre-devel x86_64 8.32-17.el7 base 480 k

Transaction Summary
=================================================================================
Install 1 Package

Total download size: 480 k
Installed size: 1.4 M
Downloading packages:
pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pcre-devel-8.32-17.el7.x86_64 1/1
Verifying : pcre-devel-8.32-17.el7.x86_64 1/1

Installed:
pcre-devel.x86_64 0:8.32-17.el7

Complete!
[root@mcw1 nginx-1.10.2]# ./configure #继续配置
checking for OS
+ Linux 3.10.0-693.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
.........
checking for md5 in system md5 library ... not found
checking for md5 in system OpenSSL crypto library ... not found
checking for sha1 in system md library ... not found
checking for sha1 in system OpenSSL crypto library ... not found
checking for zlib library ... not found

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
[root@mcw1 nginx-1.10.2]# yum install -y zlib-devel #2、缺啥装啥
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
..........
Installed:
zlib-devel.x86_64 0:1.2.7-19.el7_9

Dependency Updated:
zlib.x86_64 0:1.2.7-19.el7_9

Complete!
[root@mcw1 nginx-1.10.2]# ./configure #继续配置
checking for OS
+ Linux 3.10.0-693.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
checking for gcc -pipe switch ... found
.........
checking for zlib library ... found
creating objs/Makefile

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
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"
#这个配置统计出了,使用了什么(pcre,zlib刚刚装的两个包),没有使用什么(openssl)
这里显示了预安装路径,二进制启动文件路径,模块存放路径,配置存放路径,配置文件是什么,pid文件路径,错误日志路径,
访问日志路径,客户端请求体临时文件名,代理临时文件名,fastcgi临时文件名,uwsgi临时文件名,scgi临时文件名,等等
./configure执行这个配置脚本,没加参数,默认安装文件到上面目录,比较分散。
[root@mcw1 nginx-1.10.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@mcw1 nginx-1.10.2]# make #执行make编译命令
make -f objs/Makefile
make[1]: Entering directory `/root/nginx-1.10.2'
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
-o objs/src/core/nginx.o \
src/core/nginx.c
............
-o objs/ngx_modules.o \
objs/ngx_modules.c
cc -o objs/nginx \
objs/src/core/nginx.o \
objs/src/core/ngx_log.o \
objs/src/core/ngx_palloc.o \
objs/src/core/ngx_array.o \
objs/src/http/modules/ngx_http_upstream_zone_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lz \
-Wl,-E
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-1.10.2' #移除解压的目录
[root@mcw1 nginx-1.10.2]#
[root@mcw1 nginx-1.10.2]# ls #
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@mcw1 nginx-1.10.2]# pwd #但这个目录还是存在的
/root/nginx-1.10.2
[root@mcw1 nginx-1.10.2]# which make #make命令位置
/usr/bin/make
[root@mcw1 nginx-1.10.2]# make install #安装
make -f objs/Makefile install #制作文件
make[1]: Entering directory `/root/nginx-1.10.2'
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-1.10.2'
[root@mcw1 nginx-1.10.2]#
[root@mcw1 nginx-1.10.2]# ls /usr/local/nginx #编译安装完后可以看到,默认装到/usr/local/下了
conf html logs sbin
[root@mcw1 nginx-1.10.2]# ls /usr/local/nginx/conf/
fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf
fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default
[root@mcw1 nginx-1.10.2]# ls /usr/local/nginx/sbin/
nginx
[root@mcw1 nginx-1.10.2]# ls /usr/local/nginx/html/
50x.html index.html
[root@mcw1 nginx-1.10.2]# ls /usr/local/nginx/logs/
[root@mcw1 nginx-1.10.2]# /usr/local/nginx/sbin/nginx #启动Nginx
[root@mcw1 nginx-1.10.2]# ps -ef|grep nginx #编译安装默认只有个主进程,一个工作进程
root 6558 1 0 04:17 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 6559 6558 0 04:17 ? 00:00:00 nginx: worker process
root 6563 2879 0 04:17 pts/0 00:00:00 grep --color=auto nginx
[root@mcw1 nginx-1.10.2]# netstat -lntup|grep 80 #查看服务端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6558/nginx: master
[root@mcw1 nginx-1.10.2]#
[root@mcw1 nginx-1.10.2]# curl 10.0.0.131:80 #本地curl检验
<!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@mcw1 nginx-1.10.2]# systemctl status firewalld.service #网络查看都是通的,但是无法访问,没想到防火墙没关,自以为关掉了
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-11-02 03:27:55 CST; 56min ago
Docs: man:firewalld(1)
Main PID: 956 (firewalld)
CGroup: /system.slice/firewalld.service
└─956 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Nov 02 03:27:44 mcw1 systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 02 03:27:55 mcw1 systemd[1]: Started firewalld - dynamic firewall daemon.
Nov 02 03:27:58 mcw1 firewalld[956]: WARNING: ICMP type 'beyond-scope' is not supported by the kernel for ipv6.
Nov 02 03:27:58 mcw1 firewalld[956]: WARNING: beyond-scope: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
Nov 02 03:27:58 mcw1 firewalld[956]: WARNING: ICMP type 'failed-policy' is not supported by the kernel for ipv6.
Nov 02 03:27:58 mcw1 firewalld[956]: WARNING: failed-policy: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
Nov 02 03:27:58 mcw1 firewalld[956]: WARNING: ICMP type 'reject-route' is not supported by the kernel for ipv6.
Nov 02 03:27:58 mcw1 firewalld[956]: WARNING: reject-route: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
[root@mcw1 nginx-1.10.2]# systemctl stop firewalld.service #停掉防火墙,浏览器访问成功。有图
[root@mcw1 nginx-1.10.2]# ls #查看到Makefile文件存在
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@mcw1 nginx-1.10.2]# cat Makefile

default: build

clean:
rm -rf Makefile objs

build:
$(MAKE) -f objs/Makefile

install:
$(MAKE) -f objs/Makefile install

modules:
$(MAKE) -f objs/Makefile modules

upgrade:
/usr/local/nginx/sbin/nginx -t

kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin

kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@mcw1 nginx-1.10.2]# make clean #里面就是编译安装的入口,make拼接一下命令,删掉编译文件
rm -rf Makefile objs
[root@mcw1 nginx-1.10.2]# ls #查看已经删掉这个文件
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@mcw1 nginx-1.10.2]# cd ../
[root@mcw1 ~]# ls
anaconda-ks.cfg bootime.svg nginx-1.10.2 nginx-1.10.2.tar.gz
[root@mcw1 ~]# mv nginx-1.10.2 nginx-1.10.2bak
[root@mcw1 ~]# tar xf nginx-1.10.2
tar: nginx-1.10.2: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
[root@mcw1 ~]# ls
anaconda-ks.cfg bootime.svg nginx-1.10.2bak nginx-1.10.2.tar.gz
[root@mcw1 ~]# mv nginx-1.10.2bak inginx-1.10.2bak
[root@mcw1 ~]# tar xf nginx-1.10.2.tar.gz #重新解压Nginx包
[root@mcw1 ~]# ls
anaconda-ks.cfg bootime.svg inginx-1.10.2bak nginx-1.10.2 nginx-1.10.2.tar.gz
[root@mcw1 ~]# ls nginx-1.10.2 #查看到解压包中本来没有Makefile文件和objs目录的,
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src

再次执行configure脚本,可以在后面看到,创建了目录
creating objs/Makefile

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
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@mcw1 nginx-1.10.2]# ls #执行configure脚本后Makefile文件也存在了
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@mcw1 nginx-1.10.2]# cd ../ #删除这个目录重新解压
[root@mcw1 ~]# ls
anaconda-ks.cfg bootime.svg inginx-1.10.2bak nginx-1.10.2 nginx-1.10.2.tar.gz
[root@mcw1 ~]# rm -rf nginx-1.10.2
[root@mcw1 ~]# tar xf nginx-1.10.2.tar.gz
[root@mcw1 ~]# cd nginx-1.10.2/
[root@mcw1 nginx-1.10.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@mcw1 nginx-1.10.2]# make #不经历configure脚本执行,直接make,是找不到Makefile文件的。
make: *** No targets specified and no makefile found. Stop.
./configure --prefix=/root/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module

指定配置参数了的编译安装

./configure --prefix=/root/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
make
make install
[root@mcw1 ~]# rz #上传

[root@mcw1 ~]# ls
anaconda-ks.cfg nginx-1.10.2.tar.gz
[root@mcw1 ~]# tar xf nginx-1.10.2.tar.gz
[root@mcw1 ~]# ls
anaconda-ks.cfg nginx-1.10.2 nginx-1.10.2.tar.gz
[root@mcw1 ~]# mkdir nginx #建目录
[root@mcw1 ~]# ls
anaconda-ks.cfg nginx nginx-1.10.2 nginx-1.10.2.tar.gz
[root@mcw1 ~]# ls /root/nginx
[root@mcw1 ~]# useradd -s /sbin/nologin -M www #建用户
[root@mcw1 ~]# cd nginx-1.10.2/
[root@mcw1 nginx-1.10.2]# pwd
/root/nginx-1.10.2
[root@mcw1 nginx-1.10.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@mcw1 nginx-1.10.2]# ./configure --prefix=/root/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module #配置
.........
checking for OpenSSL library in /opt/local/ ... not found

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

#不指定参数这个pcre pcre-devel zlib-devel 要装,指定配置参数了需要装openssl了
yum install openssl openssl-devel -y
[root@mcw1 nginx-1.10.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@mcw1 nginx-1.10.2]# ls -a /root/nginx
. ..
[root@mcw1 nginx-1.10.2]#
[root@mcw1 nginx-1.10.2]# ./configure --prefix=/root/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module #继续配置
checking for zlib library ... found
creating objs/Makefile

Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library

nginx path prefix: "/root/nginx"
nginx binary file: "/root/nginx/sbin/nginx"
nginx modules path: "/root/nginx/modules"
nginx configuration prefix: "/root/nginx/conf"
nginx configuration file: "/root/nginx/conf/nginx.conf"
nginx pid file: "/root/nginx/logs/nginx.pid"
nginx error log file: "/root/nginx/logs/error.log"
nginx http access log file: "/root/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"

#可以看到现在的目录是在指定的目录下
之前的目录是:
creating objs/Makefile

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
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"

82 make
83 make install
[root@mcw1 nginx-1.10.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@mcw1 nginx-1.10.2]# cd ../nginx
[root@mcw1 nginx]# ls #成功安装
conf html logs sbin
[root@mcw1 nginx]# ls conf/
fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf
fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default
[root@mcw1 nginx]# ls html/
50x.html index.html
[root@mcw1 nginx]# ls logs/
[root@mcw1 nginx]# ls sbin/
nginx
[root@mcw1 nginx]# ll
total 0
drwxr-xr-x 2 root root 333 Nov 1 23:26 conf
drwxr-xr-x 2 root root 40 Nov 1 23:26 html
drwxr-xr-x 2 root root 6 Nov 1 23:26 logs
drwxr-xr-x 2 root root 19 Nov 1 23:26 sbin

打包解压到新的机器上,启动失败,添加用户后,访问页面403禁止访问。
[root@mcw9 ~]# ls
anaconda-ks.cfg nginx.tar.gz
[root@mcw9 ~]# tar xf nginx.tar.gz
[root@mcw9 ~]# ls
anaconda-ks.cfg nginx nginx.tar.gz
[root@mcw9 ~]# cd nginx/sbin/
[root@mcw9 sbin]# ls
nginx
[root@mcw9 sbin]# ./nginx
nginx: [emerg] getpwnam("www") failed
[root@mcw9 sbin]# useradd -s /sbin/nologin -M www
[root@mcw9 sbin]# ./nginx
[root@mcw9 sbin]# ps -ef|grep nginx #可以看到文件都是root,root启动,当时编译前 配置www用户的程序
root 2386 1 0 07:41 ? 00:00:00 nginx: master process ./nginx
www 2387 2386 0 07:41 ? 00:00:00 nginx: worker process
root 2389 2335 0 07:41 pts/0 00:00:00 grep --color=auto nginx
[root@mcw9 sbin]# systemctl stop firewalld.service
[root@mcw9 sbin]#
如下操作之后还是403错误
-rw-r--r-- 1 root root 2552885 Nov 1 23:38 nginx.tar.gz
[root@mcw9 ~]# ps -ef|grep nginx
root 2386 1 0 07:41 ? 00:00:00 nginx: master process ./nginx
www 2465 2386 0 07:50 ? 00:00:00 nginx: worker process
root 2513 2335 0 08:03 pts/0 00:00:00 grep --color=auto nginx
[root@mcw9 ~]# nginx/sbin/nginx -s stop
[root@mcw9 ~]# ps -ef|grep nginx
root 2516 2335 0 08:04 pts/0 00:00:00 grep --color=auto nginx
[root@mcw9 ~]# nginx/sbin/nginx
[root@mcw9 ~]# ps -ef|grep nginx
root 2518 1 0 08:04 ? 00:00:00 nginx: master process nginx/sbin/nginx
www 2519 2518 0 08:04 ? 00:00:00 nginx: worker process
root 2521 2335 0 08:04 pts/0 00:00:00 grep --color=auto nginx
改配置文件为www还是不行
[root@mcw9 conf]# vim nginx.conf
[root@mcw9 conf]# grep user nginx.conf
#user nobody;
user www;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '"$http_user_agent" "$http_x_forwarded_for"';
[root@mcw9 conf]# cd ../sbin/
[root@mcw9 sbin]# ./nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
^C
[root@mcw9 sbin]# ./nginx -s reload
[root@mcw9 sbin]# ./nginx -s reload
[root@mcw9 sbin]# ps -ef|grep nginx
root 2546 1 0 08:08 ? 00:00:00 nginx: master process /root/nginx/sbin/nginx -c /root/nginx/conf/nginx.conf
www 2573 2546 0 08:11 ? 00:00:00 nginx: worker process
root 2575 2335 0 08:12 pts/0 00:00:00 grep --color=auto nginx
还是得改成和启动进程的用户是一致的才能解决403禁止访问的问题。
[root@mcw9 sbin]# vim ../conf/nginx.conf
[root@mcw9 sbin]# ./nginx -s reload
[root@mcw9 sbin]# ps -ef|grep nginx #工作进程名也是root即程序启动用户就可以访问了
root 2546 1 0 08:08 ? 00:00:00 nginx: master process /root/nginx/sbin/nginx -c /root/nginx/conf/nginx.conf
root 2595 2546 0 08:13 ? 00:00:00 nginx: worker process
root 2599 2335 0 08:13 pts/0 00:00:00 grep --color=auto nginx
[root@mcw9 sbin]# grep root ../conf/nginx.conf
user root;
root html;
root html;
# root html;
# deny access to .htaccess files, if Apache's document root
# root html;
# root html;

指定依赖包位置编译安装

有时间补充

yum安装的直接就能用了

[root@mcw1 ~]# vim /etc/resolv.conf
[root@mcw1 ~]# yum install -y nginx
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/3): epel/x86_64/updateinfo | 1.0 MB 00:00:01
(2/3): epel/x86_64/primary_db | 7.0 MB 00:00:09
(3/3): updates/7/x86_64/primary_db | 12 MB 00:00:12
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.20.1-9.el7 will be installed
--> Processing Dependency: nginx-filesystem = 1:1.20.1-9.el7 for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_1)(64bit) for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: nginx-filesystem for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1()(64bit) for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.20.1-9.el7.x86_64
--> Processing Dependency: libssl.so.1.1()(64bit) for package: 1:nginx-1.20.1-9.el7.x86_64
--> Running transaction check
---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed
---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed
---> Package nginx-filesystem.noarch 1:1.20.1-9.el7 will be installed
---> Package openssl11-libs.x86_64 1:1.1.1g-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Installing:
nginx x86_64 1:1.20.1-9.el7 epel 587 k
Installing for dependencies:
centos-indexhtml noarch 7-9.el7.centos base 92 k
gperftools-libs x86_64 2.6.1-1.el7 base 272 k
nginx-filesystem noarch 1:1.20.1-9.el7 epel 24 k
openssl11-libs x86_64 1:1.1.1g-3.el7 epel 1.5 M

Transaction Summary
===============================================================================================================================================================
Install 1 Package (+4 Dependent packages)

Total download size: 2.4 M
Installed size: 6.7 M
Downloading packages:
(1/5): centos-indexhtml-7-9.el7.centos.noarch.rpm | 92 kB 00:00:00
(2/5): nginx-filesystem-1.20.1-9.el7.noarch.rpm | 24 kB 00:00:00
(3/5): gperftools-libs-2.6.1-1.el7.x86_64.rpm | 272 kB 00:00:00
(4/5): nginx-1.20.1-9.el7.x86_64.rpm | 587 kB 00:00:00
(5/5): openssl11-libs-1.1.1g-3.el7.x86_64.rpm | 1.5 MB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.6 MB/s | 2.4 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gperftools-libs-2.6.1-1.el7.x86_64 1/5
Installing : 1:nginx-filesystem-1.20.1-9.el7.noarch 2/5
Installing : 1:openssl11-libs-1.1.1g-3.el7.x86_64 3/5
Installing : centos-indexhtml-7-9.el7.centos.noarch 4/5
Installing : 1:nginx-1.20.1-9.el7.x86_64 5/5
Verifying : centos-indexhtml-7-9.el7.centos.noarch 1/5
Verifying : 1:openssl11-libs-1.1.1g-3.el7.x86_64 2/5
Verifying : 1:nginx-filesystem-1.20.1-9.el7.noarch 3/5
Verifying : gperftools-libs-2.6.1-1.el7.x86_64 4/5
Verifying : 1:nginx-1.20.1-9.el7.x86_64 5/5

Installed:
nginx.x86_64 1:1.20.1-9.el7

Dependency Installed:
centos-indexhtml.noarch 0:7-9.el7.centos gperftools-libs.x86_64 0:2.6.1-1.el7 nginx-filesystem.noarch 1:1.20.1-9.el7 openssl11-libs.x86_64 1:1.1.1g-3.el7

Complete!
[root@mcw1 ~]#
[root@mcw1 ~]#
[root@mcw1 ~]# nginx
[root@mcw1 ~]# ps -ef|grep nginx
root 4477 1 0 00:17 ? 00:00:00 nginx: master process nginx
nginx 4478 4477 0 00:17 ? 00:00:00 nginx: worker process
root 4480 3830 0 00:17 pts/1 00:00:00 grep --color=auto nginx
[root@mcw1 ~]# hostname -I
10.0.0.131 172.16.1.131
[root@mcw1 ~]# systemctl stop firewalld.service
[root@mcw1 ~]# rpm -qa|grep pcre
pcre-8.32-17.el7.x86_64
[root@mcw1 ~]#

Nginx多种安装方式的更多相关文章

  1. StreamSets学习系列之StreamSets支持多种安装方式【Core Tarball、Cloudera Parcel 、Full Tarball 、Full RPM 、Docker Image和Source Code 】(图文详解)

    不多说,直接上干货! Streamsets的官网 https://streamsets.com/ 得到 https://streamsets.com/opensource/ StreamSets支持多 ...

  2. MySQL多种安装方式选择

    1.rpm包安装方式 rpm包的安装方式非常简单,这里以el6平台下的mysql-5.6.34版本为例,首先,要通过上述搜狐镜像地址下载到如下四个MySQL相关软件安装包. a.下载安装包 MySQL ...

  3. Rainbond 5.6 版本发布,增加多种安装方式,优化拓扑图操作体验

    Rainbond 5.6 版本,主要致力于提升拓扑图操作效率以及快速安装体验,降低用户使用门槛. 主要功能点解读: 支持单机快速体验 为了方便在单机电脑上快速安装体验Rainbond,当前版本支持通过 ...

  4. Linux下软件包的多种安装方式

    源码包安装 在Linux下的很多软件都是通过源码包方式发布的,虽然相对于二进制软件包,配置和编译起来繁琐点,但是它的可移植性却好得多,针对不同的体系结构,软件开发者往往仅需发布同一份源码包,不同的最终 ...

  5. 关于TensorFlow多种安装方式

    Tensorflow的官网其实给出了很详细的安装教程,细分包括: Pip install: Install TensorFlow on your machine, possibly upgrading ...

  6. 彻底搞懂 etcd 系列文章(二):etcd 的多种安装姿势

    0 专辑概述 etcd 是云原生架构中重要的基础组件,由 CNCF 孵化托管.etcd 在微服务和 Kubernates 集群中不仅可以作为服务注册与发现,还可以作为 key-value 存储的中间件 ...

  7. Nginx常见的安装方式

    Nginx常见的安装方式 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Nginx概述 Nginx的安装版本分为开发版.稳定版和过期版, Nginx安装可以使用yum或源码安装 ...

  8. Nginx安装与使用 及在redhat 中的简单安装方式

    首先说下在redhat中的安装方法, 正常安装nginx 需要安装很多的依赖,最后再安装nginx,而且很容易出错. 在nginx官方上有这么一段描述: Pre-Built Packages for ...

  9. Nginx安装方式探究

    Ubuntu 16.04(阿里云ECS),Nginx 1.10.3 (Ubuntu) 本文探究两种安装方式: 1.源码安装(手动) 2.APT安装(自动) 源码安装(手动) 步骤简介: 下载.解压.. ...

随机推荐

  1. Linux系列(37) - 源码包与RPM包区别(1)

    源码包是不能使用[service]命令来启动服务,因为源码包的安装位置由用户指定 源码包一般安装在: /usr/local/软件名/ ,源码包安装的服务,只能用绝对路径进行服务的管理 rpm包安装后, ...

  2. DevOps与CICD简介

    整体知识点 ·Devops与CI/CD简介 ·Gitlab安装与Git命令使用 ·Gitlab实现持续集成 ·Gitlab实现分支管理 ·Jenkins简介及安装 ·Jenkins插件管理及基础配置 ...

  3. jQuery has been removed

    jQuery has been removed, 新的项目不要用jQuery了 这些问题都已经有了解决方案 * $()选择器, * $.ajax, * $dom.on("click" ...

  4. nginx rewrite重写规则集合

    本文根据网络搜索整理,不是原创 一.正则表达式匹配,其中: ~ 为区分大小写匹配 ~* 为不区分大小写匹配 !~和!~* 分别为区分大小写不匹配及不区分大小写不匹配 . 匹配除换行符以外的任意字符 \ ...

  5. 鸿蒙内核源码分析(文件概念篇) | 为什么说一切皆是文件 | 百篇博客分析OpenHarmony源码 | v62.01

    百篇博客系列篇.本篇为: v62.xx 鸿蒙内核源码分析(文件概念篇) | 为什么说一切皆是文件 | 51.c.h.o 本篇开始说文件系统,它是内核五大模块之一,甚至有Linux的设计哲学是" ...

  6. ASP.NET Core 中间件的使用(三):全局异常处理机制

    前言 我们经常听到"秒修复秒上线",觉得很厉害的样子. 其实不然,这只是一个调侃而已,出现问题的方式很多(逻辑漏洞.代码异常.操作方式不正确等). 我们今天来说代码异常问题怎么快速 ...

  7. UTF-8和Unicode编码

    常用的能够保存汉字的编码表有UTF-8.GBK等.需要注意,无论文件使用的是什么编码格式,读取到Java程序中,所有的字符都是用Unicode编码表示(Java中所有的字符内容都使用char类型表示, ...

  8. WPF进阶技巧和实战08-依赖属性与绑定02

    将元素绑定在一起 数据绑定最简单的形式是:源对象是WPF元素而且源属性是依赖项属性.依赖项属性内置了更改通知支持,当源对象中改变依赖项属性时,会立即更新目标对象的绑定属性. 元素绑定到元素也是经常使用 ...

  9. Windows下的程序及热键监视神器——Spy++

    Windows下的程序及热键监视神器--Spy++ 背景 在使用Windows的时候,偶尔会发现某些应用程序的热键不生效了:又或是桌面弹出了弹框却并不知道这个弹框来自何处.例如,本人最近使用Vim的时 ...

  10. Mysql读写分离集群的搭建且与MyCat进行整合

    1. 概述 老话说的好:不熟悉的东西不要不懂装懂,做人要坦诚,知道就是知道,不知道就是不知道. 言归正传,今天我们来聊聊 Mysql主从读写分离集群是如何搭建的,并且聊一下如何用 MyCat 去访问这 ...