09 通过Nginx源码简单安装

09 通过Nginx源码简单安装

09.1 下载nginx

下载nginx版本:nginx-1.16.1

网页版下载:https://nginx.org/en/download.html  再上传到服务器

# 终端命令行下载
[root@nginx-100 ~]# wget https://nginx.org/download/nginx-1.16.1.tar.gz

09.2 目录管理

[root@nginx-100 ~]# mkdir -p nginx/core
[root@nginx-100 ~]# mv nginx-1.16.1.tar.gz nginx/core/
[root@nginx-100 ~]# ls -ltr nginx/core/
total 1012
-rw-r--r-- 1 root root 1032630 Aug 14  2019 nginx-1.16.1.tar.gz

09.3 解压

[root@nginx-100 ~]# cd nginx/core/
[root@nginx-100 ~/nginx/core]# tar -zxf nginx-1.16.1.tar.gz 
[root@nginx-100 ~/nginx/core]# ls -ltr
total 1012
drwxr-xr-x 8 1001 1001     158 Aug 13  2019 nginx-1.16.1
-rw-r--r-- 1 root root 1032630 Aug 14  2019 nginx-1.16.1.tar.gz

09.4 配置

[root@nginx-100 ~/nginx/core]# cd nginx-1.16.1/
[root@nginx-100 ~/nginx/core/nginx-1.16.1]# ls -ltr
total 748
-rw-r--r-- 1 1001 1001     49 Aug 13  2019 README
-rw-r--r-- 1 1001 1001   1397 Aug 13  2019 LICENSE
-rwxr-xr-x 1 1001 1001   2502 Aug 13  2019 configure
-rw-r--r-- 1 1001 1001 452171 Aug 13  2019 CHANGES.ru
-rw-r--r-- 1 1001 1001 296463 Aug 13  2019 CHANGES
drwxr-xr-x 9 1001 1001     91 Mar 10 23:14 src
drwxr-xr-x 2 1001 1001     21 Mar 10 23:14 man
drwxr-xr-x 2 1001 1001     40 Mar 10 23:14 html
drwxr-xr-x 4 1001 1001     72 Mar 10 23:14 contrib
drwxr-xr-x 2 1001 1001    168 Mar 10 23:14 conf
drwxr-xr-x 6 1001 1001    326 Mar 10 23:14 auto
# 配置 [root@nginx
-100 ~/nginx/core/nginx-1.16.1]# ./configure ..........

09.5 编译及安装

[root@nginx-100 ~/nginx/core/nginx-1.16.1]# make && make install
..........
# 默认安装路径,可以通过参数指定
[root@nginx-100 ~/nginx/core/nginx-1.16.1]# cd /usr/local/nginx/
[root@nginx-100 /usr/local/nginx]# ls -ltr
total 0
drwxr-xr-x 2 root root  19 Mar 10 23:21 sbin
drwxr-xr-x 2 root root 333 Mar 10 23:21 conf
drwxr-xr-x 2 root root   6 Mar 10 23:21 logs
drwxr-xr-x 2 root root  40 Mar 10 23:21 html

09.6 启动nginx

[root@nginx-100 /usr/local/nginx]# cd sbin/
[root@nginx-100 /usr/local/nginx/sbin]# ls -ltr
total 3736
-rwxr-xr-x 1 root root 3825560 Mar 10 23:21 nginx
[root@nginx-100 /usr/local/nginx/sbin]# ./nginx 
[root@nginx-100 /usr/local/nginx/sbin]# ps -ef|grep nginx
root       4201      1  0 23:25 ?        00:00:00 nginx: master process ./nginx
nobody     4202   4201  0 23:25 ?        00:00:00 nginx: worker process
root       4204   1459  0 23:25 pts/0    00:00:00 grep --color=auto nginx
[root@nginx-100 /usr/local/nginx/sbin]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:80:e0:d5 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe80:e0d5/64 scope link 
       valid_lft forever preferred_lft forever

浏览器访问:http://10.0.0.100/

image

 

———————————————————————————————————————————————————————————————————————————

                                                                                                                         无敌小马爱学习

posted on 2026-03-10 17:53  马俊南  阅读(2)  评论(0)    收藏  举报