Linux 利用nginx原始碼編譯安裝nginx

2021-08-10 21:49:15 字數 1787 閱讀 7199

1, centos 7

2, nginx 1.13.6

1,編譯前準備

yum install pcre* openssl openssl-devel  zlib zlib-devel
cd /usr/local/src

wget

.6.tar

.gz

3,解壓nginx原始碼

tar -xzvf nginx-1.13

.6.tar

.gzchown -r root:root nginx-1.13

.6

5,編譯nginx

cd

/usr/local/src/nginx-1

.13.6

./configure--

group=nginx--

user=nginx--

prefix=/usr/local/nginx--

sbin

-path=/usr/sbin/nginx

make

5,安裝nginx

make install
6,啟動nginx

/usr/local/nginx/sbin/nginx
7,檢視nginx是否啟動

ps -ef | grep nginx
8,檢視80埠返回的內容

curl

localhost

:80

9,新增為系統服務

vi /usr/lib/systemd/system/nginx.service

------------------------------------------

[unit]

description=nginx - high performance web server

documentation=

after=network-online.target remote-fs.target nss-lookup.target

wants=network-online.target

[service]

type=forking

pidfile=/var/run/nginx.pid

execstartpre=/usr/sbin/nginx -t

execstart=/usr/sbin/nginx

execreload=/bin/kill -s hup $mainpid

execstop=/bin/kill -s term $mainpid

[install]

wantedby=multi-user.target

vi /usr/local/nginx/conf/nginx.conf

-------------------------------------

...pid /var/run/nginx.pid;

...檢視nginx服務是否自啟動

------------------------------------

systemctl list-unit-files|grep nginx

設定nginx服務開機後自啟動

------------------------------------

systemctl enable nginx

Nginx原始碼安裝 Linux

wget2.解壓安裝包 tar xvf nginx 1.14.2.tar.gz3.編譯 cd nginx 1.14.2 configure prefix usr local nginx user www group www with http stub status module with http...

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...