編譯安裝Nginx

2021-10-17 14:08:32 字數 2701 閱讀 3312

配置編譯選項:

[root@localhost src]# cd nginx-

1.12

.2[root@localhost nginx-

1.12

.2]# .

/configure --prefix=

/usr/local/nginx/

編譯安裝:

[root@localhost nginx-

1.12

.2]# make && make install

編寫啟動指令碼:

儲存退出;

更改許可權:

[root@localhost nginx-

1.12

.2]# chmod 755

/etc/init.d/nginx

[root@localhost nginx-

1.12

.2]# chkconfig nginx on

[root@localhost nginx-

1.12

.2]# chkconfig --add nginx

更改nginx配置檔案:

先清空之前的配置檔案:

[root@localhost nginx-

1.12

.2]# >

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

編寫:[root@localhost nginx-

}}儲存退出;檢驗是否有錯:

[root@localhost nginx-

1.12

.2]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

配置成功

啟動nginx:

[root@localhost nginx-

1.12

.2]# service nginx start

starting nginx

(via systemctl):[

ok]

測試是否正確解析php:

[root@localhost nginx-

1.12

.2]# vi /usr/local/nginx/html/

2.php

<

?php

echo "test php scripts.";?

>

[root@localhost nginx-

1.12

.2]# curl localhost/

2.php

test php[root@localhost nginx-

1.12

.2]#

解析成功;

nginx編譯安裝

nginx版本 1.12.2 1.安裝依賴包 yum install y gcc gcc c zlib zlib devel openssl openssl devel pcre pcre devel 2.編譯和安裝nginx 執行如下命令 3.安裝完成啟動nginx。如果用指定使用者啟動nginx...

Nginx編譯安裝

ububtu apt get install build essential apt get install libtool centos yum y install gcc automake autoconf libtool make yum install gcc gcc c 1 pcre庫 a...

編譯安裝Nginx

假設所有依賴都已解決,如遇到未安裝的程式則安裝後繼續 架設使用最高許可權使用者,如果不是則在命令前加上sudo 解壓到使用者目錄 tar zxvf nginx 1.6.2.tar.gz 配置安裝選項 編譯程式 make 安裝程式 make install 啟動程式 usr local nginx s...