Linux安装和配置Nignx
一、Nginx下载
说明:在Linux中采用在线下载的形式,直接从Nginx的官网获取安装包
(1)官网下载地址:http://nginx.org/download/nginx-1.19.1.tar.gz
- 右击要下载的文件,复制链接地址即可
(2)终端使用命令:wget 下载地址
[root@localhost src]# wget http://nginx.org/download/nginx-1.19.1.tar.gz
二、安装和配置Nginx
(1)解压下载好的文件
[root@localhost src]# tar -xvf nginx-1.19.1.tar.gz
(2)配置Nginx
- Nginx源文件目录,只负责编译,不负责执行
- Nginx生成可执行文件
步骤1: 生成可执行文件
[root@localhost nginx-1.19.1]# ./configure
步骤2: 编译
[root@localhost nginx-1.19.1]# make
步骤3: 安装nginx
[root@localhost nginx-1.19.1]# make install
步骤4: 获取nginx工作目录
[root@localhost nginx-1.19.1]# whereis nginx
- Nginx命令
说明: 到Nginx的工作目录(运行目录): /usr/local/nginx
[root@localhost nginx-1.19.1]# whereis nginx
nginx: /usr/local/nginx
[root@localhost nginx-1.19.1]# cd /usr/local/nginx
[root@localhost nginx]# ls
conf html logs sbin
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ls
nginx
[root@localhost sbin]#
Nginx相关命令:
- 启动:./nginx
- 重启:./nginx -s reload
- 停止:./nginx -s stop
[root@localhost sbin]# ./nginx
[root@localhost sbin]# ./nginx -s reload
[root@localhost sbin]# ./nginx -s stop