Nginx 原始碼安裝

2021-08-17 14:54:09 字數 4864 閱讀 6945

安裝pcre庫是為了讓nginx支援具備uri重寫功能的rewrite模組

[root@www ~]# yum install pcre pcre-devel -y

[root@www ~]# rpm -qa pcre pcre-devel

安裝nginx 依賴的包 openssl-devel

[root@www ~]# yum install openssl openssl-devel 

[root@www ~]# rpm -qa openssl openssl-devel

[root@www tools]# wget -q
解壓

[root@www nginx-1.9.2]# tar xf nginx-1.9.2.tar.gz

[root@www nginx-1.9.2]# cd nginx-1.9.2

配置檔案

-http_ssl_module

安裝

[root@www nginx-1.9.2]# make

[root@www nginx-1.9.2]# make install

建立軟連線

lrwxrwxrwx 1 root root 25

jan703:

檢測nginx 配置檔案知否正確

[root@www nginx-1.9

nginx: the configuration

.2//conf/nginx.conf syntax is ok

nginx: configuration

.2//conf/nginx.conf test is successful

啟動nginx

檢視nginx服務對應的埠是否成功啟動

tcp *:http (listen)

在防火牆上開端口

#檢視防火牆上已經開啟的埠`

[root@www nginx]# firewall-cmd --zone=public --list-port

#在防火牆上永久開啟80埠

[root@www nginx]# firewall-cmd --zone=public --add-port=80/tcp --permanent

#重新載入

[root@www nginx]# firewall-cmd --reload

檢視nginx 的目錄結構

├── client_body_temp

├── conf

│   ├── fastcgi.conf

│   ├── fastcgi.conf

.default

│   ├── fastcgi_params

│   ├── fastcgi_params.default

│   ├── koi-utf

│   ├── koi-win

│   ├── mime.types

│   ├── mime.types

.default

│   ├── nginx.conf

│   ├── nginx.conf

.default

│   ├── scgi_params

│   ├── scgi_params.default

│   ├── uwsgi_params

│   ├── uwsgi_params.default

│   └── win-utf

├── fastcgi_temp

├── html

│   ├── 50

x.html

│   └── index.html

├── logs

│   ├── access.log

│   ├── error.log

│   └── nginx.pid

├── proxy_temp

├── sbin

│   └── nginx

├── scgi_temp

└── uwsgi_temp

編輯nginx的配置檔案

}修改完了配置檔案,我們知道虛擬主機的關鍵部分是server{}括號中內容

根據配置的虛擬主機的根目錄,建立站點目錄和檔案,因為nginx編譯安裝的時候預設的站定目錄是html,所以在改目錄下建立

[root@master conf]# mkdir ../html/www -p

[root@master conf]# echo "" > ../html/www/index.html

[root@master conf]# cat ../html/www/index.html

[root@master conf]# ../sbin/nginx -t

nginx: the configuration

.2//conf/nginx.conf syntax is ok

nginx: configuration

.2//conf/nginx.conf test is successful

[root@master conf]# ../sbin/nginx -s reload
[root@master conf]# ps -ef|grep nginx

root 10820

1nginx 11152

10820

0 09:54 ? 00:00:00 nginx: worker process

root 11154

11088

0 09:54 pts/1

00:00:00

grep --color=auto nginx

[root@master conf]# echo "192.168.85.129 www.one.com" >>/etc/hosts

[root@master conf]# tail /etc/hosts

127.0

.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168

.85.130 www.one

.com

[root@master conf]# curl www.one.com

.com

#本地測試成功

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

Nginx原始碼安裝

解壓 tar zxvf nginx 1.10.0.tar.gz 執行下面的命令安裝nginx的依賴庫 yum y install gcc pcre pcre devel zlib zlib devel openssl openssl devel我這裡只配置安裝到 opt目錄下,其它選項可執行.con...

nginx 原始碼安裝

缺少 pcre 安裝包 筆者用的是ubuntu apt install libpcre3 libpcre3 dev 缺少 openssl 安裝包 筆者用的是ubuntu apt install openssl apt install libssl dev 再次執行 nginx 指令碼內容 1 bin...