先安装Nginx 所需环境
安装make:yum -y install autoconf automake make
安装g++: yum -y install gcc gcc-c++
#一般系统中已经装了了make和g++,无须再装
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum install -y openssl openssl-devel
#安装nginx依赖的库
下载压缩包
wget http://nginx.org/download/nginx-1.15.8.tar.gz
解压
tar -zxvf nginx-1.15.8.tar.gz
进入解压后目录
cd nginx-1.15.8
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
#配置
#--prefix指定安装目录
#--with-http_ssl_module安装https模块
#creating objs/Makefile 代表编译成功
make && make install
#make编译
#make install安装
查看安装位置
whereis nginx
配置环境变量
vim /etc/profile
在文件末尾添加
export PATH=$PATH:/usr/local/nginx/sbin/
使新增的配置生效
source /etc/profile
启动 nginx
nginx
查看是否启动
- Nginx目录结构:
- Conf 配置文件
- Html 网页文件
- Logs 日志文件
- Sbin 二进制程序
- 2Nginx常用命令
启停命令:
./nginx -c nginx.conf的文件。如果不指定,默认为NGINX_HOME/conf/nginx.conf
./nginx -s stop 停止
./nginx -s quit退出
./nginx -s reload 重新加载nginx.conf