Linux下Nginx安装并启动

1、官网下载:

点我下载或访问官网自行下载

2、安装nginx需要的环境:
yum -y install gcc-c++
yum -y install -y pcre pcre-devel
yum -y install -y zlib zlib-devel
yum -y install -y openssl openssl-devel
yum -y install pcre-devel
yum -y install openssl openssl-devel
3、上传并解压:
/usr/local #上传至此目录
tar -zxvf nginx-1.18.0.tar.gz #解压
cd nginx-1.18.0/ #进入
mkdir /var/temp/nginx -p #先建个临时目录
4、编译:

在目录下运行此命令:

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi

之后运行编译:

make
make install

至此可以看到nginx已经安装成功:

[root@instance-c38a6f8r nginx-1.18.0]# whereis nginx
nginx: /usr/local/nginx

目录介绍:

[root@instance-c38a6f8r nginx-1.18.0]# cd /usr/local/nginx
[root@instance-c38a6f8r nginx]# ll
total 12
drwxr-xr-x 2 root root 4096 May 15 00:30 conf #配置文件
drwxr-xr-x 2 root root 4096 May 15 00:30 html #静态资源文件夹
drwxr-xr-x 2 root root 4096 May 15 00:30 sbin #二进制文件,在此文件夹运行
5、运行Nginx:
[root@instance-c38a6f8r nginx]# cd sbin/
-rwxr-xr-x 1 root root 3883728 May 15 00:30 nginx #sbin只有一个nginx文件
[root@instance-c38a6f8r sbin]# ./nginx #运行

到这里就启动完成了,访问网站则会出现欢迎页
遇到问题的朋友可以留言,看到回复
在这里插入图片描述
常用的一些命令:

[root@instance-c38a6f8r sbin]# ./nginx #运行
[root@instance-c38a6f8r sbin]# ./nginx -s reload #重新加载
[root@instance-c38a6f8r sbin]# ./nginx -s quit #优雅的停止或者stop强行停止
[root@instance-c38a6f8r sbin]# ./nginx -t #检测nginx配置文件是否正确
[root@instance-c38a6f8r sbin]# ./nginx -v #查看当前版本
[root@instance-c38a6f8r sbin]# ./nginx -V #查看版本已经各种日志的配置路径
[root@instance-c38a6f8r sbin]# ./nginx -c filename #切换配置文件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

素人岳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值