wget
2.解壓安裝包
tar -xvf nginx-1.14.2.tar.gz
3.編譯
問題:編譯可能發報錯,nginx需要zlib,pcre,openssl 支援 ,安裝即可cd nginx-1.14.2
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
zlib:yum install -y zlib
yum install -y openssl openssl-devel
yum install -y pcre pcre-devel
pcre:
openssl:
安裝過程很簡單,直接常規安裝即可
./configure && make && make install
4. 新增nginx執行使用者
啟動nginxgroupadd www
useradd -g www -s /sbin/nologin www
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
5.設定服務指令碼
把下面的shell指令碼儲存成檔名為 nginx ,新增到 /etc/init.d 目錄下
nginx的原始命令列管理如下:#!/bin/bash
## chkconfig: - 85 15
# description: nginx is a world wide web server.
# processname: nginx
nginx=/usr/local/nginx/sbin/nginx # 根據安裝目錄自定義設定
conf=/usr/local/nginx/conf/nginx.conf # 根據安裝目錄自定義設定
case $1 in
start)
echo -n "starting nginx"
$nginx -c $conf
echo " done"
;;stop)
echo -n "stopping nginx"
killall -9 nginx
echo " done"
;;test)
$nginx -t -c $conf
;;reload)
echo -n "reloading nginx"
ps auxww | grep nginx | grep master | awk '' | xargs kill -hup
echo " done"
;;restart)
$0 stop
$0 start
;;show)
ps -aux|grep nginx
;;*)
echo -n "usage: $0 "
;;esac
服務啟動命令驗證配置是否正確: nginx -t
檢視nginx的版本號:nginx -v
快速停止或關閉nginx:nginx -s stop
正常停止或關閉nginx:nginx -s quit
配置檔案修改重裝載命令:nginx -s reload
service start|restart|reload|stop|test|show
6. 設定開機啟動
7.新增新的nginx模組chkconfig --add nginx #新增服務進開機啟動
chkconfig nginx on #設定成開機啟動
chkconfig --list nginx # 檢視開機啟動狀態
進入nginx原始碼模組,重新編譯,然後make,把objs中的ngnix檔案替換掉原來sbin/nginx,重啟nginx
linux下 原始碼安裝nginx
inux系統為centos 64位 第二步 解壓 tar zxvf nginx 1.5.9.tar.gz mv到 usr local nginx目錄下 第三步 設定一下配置資訊 configure prefix usr local nginx 或者不執行此步,直接預設配置 第四步 make 編譯 m...
linux下Nginx原始碼安裝
cd nignx wget 2 原始碼解壓到 usr src目錄 tar xzvf nginx 1.14.2.tar.gz 3 安裝依賴 yum y install gcc pcre pcre devel perl extutils embed zlib zlib devel openssl ope...
nginx原始碼安裝
nginx原始碼安裝 安裝環境 作業系統 ubuntu 12.04 nginx v1.4.2 pcre v8.33 zlib v1.2.8 1.安裝zlib 1 解壓縮 plain tdtc100 ubuntu tar zxvf zlib 1.2.8.tar.gz 2 安裝 plain tdtc10...