0


wget命令之Nginx(二)

nginx(“引擎 X”)是一个 HTTP Web 服务器、反向代理、 内容缓存、负载均衡器、 TCP/UDP 代理服务器、 和邮件代理服务器。

nginxhttps://nginx.org/en/

1.安装wget

yum install -y wget

[root@kingking ~]# yum install -y wget
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • epel: mirrors.hostiserver.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    软件包 wget-1.14-18.el7_6.1.x86_64 已安装并且是最新版本
    无须任何处理

[root@kingking ~]#

1.1查看

wget -V

[root@kingking ~]# wget -V
GNU Wget 1.14 在 linux-gnu 上编译。

+digest +https +ipv6 +iri +large-file +nls +ntlm +opie +ssl/openssl

Wgetrc:
/etc/wgetrc (系统)
字符集: /usr/share/locale
编译: gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
-DLOCALEDIR="/usr/share/locale" -I. -I../lib -I../lib -O2 -g -pipe
-Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
链接程序: gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches -m64 -mtune=generic -lssl -lcrypto
/usr/lib64/libssl.so /usr/lib64/libcrypto.so /usr/lib64/libz.so
-ldl -lz -lz -lidn -luuid -lpcre ftp-opie.o openssl.o http-ntlm.o
../lib/libgnu.a

Copyright (C) 2011 Free Software Foundation, Inc.
授权 GPLv3+: GNU GPL 第三版或更高版本
http://www.gnu.org/licenses/gpl.html
这是自由软件:您可以自由地更改并重新分发它。
在法律所允许的范围内,没有任何担保。

最初由 Hrvoje Nikšić hniksic@xemacs.org 编写。
请将错误报告或建议寄给 bug-wget@gnu.org

[root@kingking ~]#

2.安装nginx

这里以1.8版本为例

wget http://nginx.org/download/nginx-1.8.0.tar.gz

[root@kingking ~]# wget http://nginx.org/download/nginx-1.8.0.tar.gz
--2024-11-05 11:05:32-- http://nginx.org/download/nginx-1.8.0.tar.gz
正在解析主机 nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:5c0:2601::6, ...
正在连接 nginx.org (nginx.org)|3.125.197.172|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:832104 (813K) [application/octet-stream]
正在保存至: “nginx-1.8.0.tar.gz”

100%[==========================================================================================>] 832,104 533KB/s 用时 1.5s

2024-11-05 11:05:34 (533 KB/s) - 已保存 “nginx-1.8.0.tar.gz” [832104/832104])

[root@kingking ~]#

3.解压到/usr/local/下

tar -xzvf nginx-1.8.0.tar.gz  -C /usr/local/

[root@kingking ~]# tar -xzvf nginx-1.8.0.tar.gz -C /usr/local/
nginx-1.8.0/
nginx-1.8.0/auto/
nginx-1.8.0/conf/
nginx-1.8.0/contrib/
nginx-1.8.0/src/
nginx-1.8.0/configure
nginx-1.8.0/LICENSE
nginx-1.8.0/README
nginx-1.8.0/html/
nginx-1.8.0/man/
nginx-1.8.0/CHANGES.ru
nginx-1.8.0/CHANGES
nginx-1.8.0/man/nginx.8
nginx-1.8.0/html/50x.html
nginx-1.8.0/html/index.html

......
[root@kingking ~]#

参数说明

  1. **-x**:表示解压(extract)一个压缩包。
  2. **-z**:表示通过 gzip 来解压文件。
  3. **-v**:表示详细模式(verbose),在解压的过程中会显示解压的文件名。
  4. **-f**:表示接下来的参数是要操作的文件名。
  5. **-C **指定解压的目标目录。

4.生成Makefike文件

cd /usr/local/nginx-1.8.0
./configure

[root@kingking nginx-1.8.0]# ./configure
checking for OS

  • Linux 3.10.0-1160.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-44) (GCC)
    checking for gcc -pipe switch ... found
    checking for gcc builtin atomic operations ... found
    checking for C99 variadic macros ... found
    checking for gcc variadic macros ... found
    checking for unistd.h ... found
    checking for inttypes.h ... found
    checking for limits.h ... found
    checking for sys/filio.h ... not found
    checking for sys/param.h ... found
    checking for sys/mount.h ... found
    checking for sys/statvfs.h ... found
    checking for crypt.h ... found
    checking for Linux specific features
    checking for epoll ... found
    checking for EPOLLRDHUP ... found
    checking for O_PATH ... found
    checking for sendfile() ... found
    checking for sendfile64() ... found
    checking for sys/prctl.h ... found
    checking for prctl(PR_SET_DUMPABLE) ... found
    checking for sched_setaffinity() ... found
    checking for crypt_r() ... found
    checking for sys/vfs.h ... found
    checking for nobody group ... found

......
[root@kingking nginx-1.8.0]#

4.1查看

ll

[root@kingking nginx-1.8.0]# ll
总用量 632
drwxr-xr-x 6 1001 1001 312 11月 5 10:51 auto
-rw-r--r-- 1 1001 1001 249124 4月 21 2015 CHANGES
-rw-r--r-- 1 1001 1001 379021 4月 21 2015 CHANGES.ru
drwxr-xr-x 2 1001 1001 168 11月 5 10:51 conf
-rwxr-xr-x 1 1001 1001 2478 4月 21 2015 configure
drwxr-xr-x 4 1001 1001 72 11月 5 10:51 contrib
drwxr-xr-x 2 1001 1001 40 11月 5 10:51 html
-rw-r--r-- 1 1001 1001 1397 4月 21 2015 LICENSE
-rw-r--r-- 1 root root 366 11月 5 10:57 Makefile
drwxr-xr-x 2 1001 1001 21 11月 5 10:51 man
drwxr-xr-x 3 root root 125 11月 5 10:57 objs
-rw-r--r-- 1 1001 1001 49 4月 21 2015 README
drwxr-xr-x 8 1001 1001 77 11月 5 10:51 src
[root@kingking nginx-1.8.0]#

5.编译

make && make install

[root@kingking nginx-1.8.0]# make && make install
make -f objs/Makefile
make[1]: 进入目录“/usr/local/nginx-1.8.0”
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
......

[root@kingking nginx-1.8.0]#

6.查看

ll /usr/local

[root@kingking nginx-1.8.0]# ll /usr/local/
总用量 0
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x 6 root root 54 11月 5 11:24 nginx
drwxr-xr-x 9 1001 1001 186 11月 5 10:56 nginx-1.8.0
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 11月 6 2023 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@kingking nginx-1.8.0]#

7.启动并关闭防火墙

关闭防火墙

systemctl stop firewalld
systemctl disable  firewalld
systemctl status firewalld

[root@kingking sbin]# systemctl stop firewalld
[root@kingking sbin]# systemctl disable firewalld
[root@kingking sbin]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@kingking sbin]#

启动nginx

cd /usr/local/nginx/sbin
./nginx

[root@kingking nginx-1.8.0]# cd /usr/local/nginx/sbin/
[root@kingking sbin]# ./nginx

补充:

关闭 ./nginx -s stop

重载 ./nginx -s reload

8.访问

虚拟机访问

curl http://localhost

[root@kingking sbin]# curl http://localhost
<!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>

Welcome to nginx!


If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

</body> </html>

[root@kingking sbin]#

浏览器访问 http://ip

如果是端口转发,注意开放端口

云服务器需要开放安全组

标签: nginx 运维 linux

本文转载自: https://blog.csdn.net/2201_75729949/article/details/143591723
版权归原作者 纯小白是我 所有, 如有侵权,请联系我们删除。

“wget命令之Nginx(二)”的评论:

还没有评论