先安裝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