CentOS系統(tǒng)編譯安裝實(shí)例詳解

centos系統(tǒng)編譯安裝lnmp環(huán)境是每來一臺(tái)新服務(wù)器或換電腦都需要做的事情、這里僅做一個(gè)記錄。給初學(xué)者一個(gè)參考!

一、安裝前的環(huán)境

這里用的是centos 7系統(tǒng)。

我們默認(rèn)把下載的軟件放在 /data/soft? (可以根據(jù)個(gè)人喜好設(shè)定)

默認(rèn)把服務(wù)器應(yīng)用安裝在 /data/apps 下面(可以根據(jù)個(gè)人喜好設(shè)定)

獲取nginx包

configure –sbin-path=/user/local/nginx/nginx –conf-path=/usr/local/nginx/nginx.conf –pid-path=/usr/local/nginx/nginx.pid

報(bào)錯(cuò)

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using –without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using –with-pcre= option

獲取pcre包

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

安裝pcre

cd /usr/local/src

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz

tar -zxvf pcre-8.37.tar.gz

cd pcre-8.34

./configure –prefix=/usr/local/pcre

make

make install

報(bào)錯(cuò)

configure: error: You need a C++ compiler for C++ support.

安裝gcc

yum install gcc gcc-c++

再次安裝pcre,成功安裝pcre

重新安裝nginx

./configure –sbin-path=/user/local/nginx/nginx –conf-path=/usr/local/nginx/nginx.conf –pid-path=/usr/local/nginx/nginx.pid

報(bào)錯(cuò)

./configure: error: the HTTP gzip module requires the zlib library.

You can either disable the module by using –without-http_gzip_module

option, or install the zlib library into the system, or build the zlib library

statically from the source with nginx by using –with-zlib= option.

安裝zlib

獲取zlib包

[root@bogon src]# tar -zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure –prefix=/usr/local/zlib

make && make install

重新安裝nginx

./configure –sbin-path=/user/local/nginx/nginx –conf-path=/usr/local/nginx/nginx.conf –pid-path=/usr/local/nginx/nginx.pid

make && make install

啟動(dòng)

[root@bogon nginx]# systemctl start nginx

Failed to start nginx.service: Unit nginx.service failed to load: No such file or directory.

說明安裝失敗

是不是沒有安裝ssl呢,我查到系統(tǒng)是有安裝的,不放心我就再安裝一次吧.

./config –prefix=/usr/local –openssldir=/usr/local/ssl

make && make install

./config shared –prefix=/usr/local –openssldir=/usr/local/ssl

make clean

make && make install

看來還是照著教程安裝才算靠譜

刪除zlib pcre

到對(duì)應(yīng)目錄運(yùn)行 make uninstall

安裝pcre

cd /usr/local/src

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz

tar -zxvf pcre-8.37.tar.gz

cd pcre-8.34

./configure –prefix=/usr/local/pcre

make

make install

?

安裝zlib

獲取zlib包

[root@bogon src]# tar -zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure –prefix=/usr/local/zlib

make && make install

重新安裝nginx

./configure –sbin-path=/usr/local/nginx/nginx

–conf-path=/usr/local/nginx/nginx.conf

–pid-path=/usr/local/nginx/nginx.pid

–with-http_ssl_module

–with-pcre=/usr/local/src/pcre-8.40

–with-zlib=/usr/local/src/zlib-1.2.11

–with-openssl=/usr/local/src/openssl-1.0.2l

?

[root@bogon nginx-1.12.0]# ./configure –sbin-path=/usr/local/nginx/nginx

> –conf-path=/usr/local/nginx/nginx.conf

> –pid-path=/usr/local/nginx/nginx.pid

local/src/openssl-1.0.2l> –with-http_ssl_module

> –with-pcre=/usr/local/src/pcre-8.40

> –with-zlib=/usr/local/src/zlib-1.2.11

> –with-openssl=/usr/local/src/openssl-1.0.2l

[root@bogon nginx-1.12.0]#?make && make install

修改/etc/local/nginx/nginx.conf 將lisent商品80改為8080

啟動(dòng)服務(wù):/etc/local/nginx/nginx

訪問:192.168.158.128:8080

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.

Commercial support is available at nginx.com.

Thank you for using nginx.

啟動(dòng)nginx服務(wù)

方法一:

/usr/local/nginx/nginx

方法二(-c nginx配置文件地址):

/usr/local/nginx/nginx -c /usr/local/nginx/nginx.conf

停止nginx服務(wù)

方法一:從容停止

查看進(jìn)程

[root@bogon nginx]# ps -ef | grep nginx

root 62024 1 0 07:01 ? 00:00:00 nginx: master process /usr/local/nginx/nginx

nobody 62025 62024 0 07:01 ? 00:00:00 nginx: worker process

root 62308 18453 0 07:14 pts/1 00:00:00 grep –color=auto nginx

殺死進(jìn)程

[root@bogon nginx]# kill -QUIT 62024

方法二:快速停止

查看進(jìn)程

[root@bogon nginx]# ps -ef | grep nginx

root 62358 1 0 07:17 ? 00:00:00 nginx: master process /usr/local/nginx/nginx -c /usr/local/nginx/nginx.conf

nobody 62359 62358 0 07:17 ? 00:00:00 nginx: worker process

root 62463 18453 0 07:20 pts/1 00:00:00 grep –color=auto nginx

殺死進(jìn)程

[root@bogon nginx]# kill -TERM 62358

或者

[root@bogon nginx]# /usr/local/nginx/nginx -c /usr/local/nginx/nginx.conf

[root@bogon nginx]# ps -ef | grep nginx

root 62473 1 0 07:21 ? 00:00:00 nginx: master process /usr/local/nginx/nginx -c /usr/local/nginx/nginx.conf

nobody 62474 62473 0 07:21 ? 00:00:00 nginx: worker process

root 62476 18453 0 07:21 pts/1 00:00:00 grep –color=auto nginx

[root@bogon nginx]# kill -INT 62473

方法三:強(qiáng)制停止

[root@bogon nginx]# pkill -9 nginx

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊15 分享