CentOS系统编译安装实例详解


本文摘自PHP中文网,作者零下一度,侵删。

CentOS系统编译安装LNMP环境是每来一台新服务器或换电脑都需要做的事情、这里仅做一个记录。给初学者一个参考!

一、安装前的环境

这里用的是CentOS 7系统。

我们默认把下载的软件放在 /data/soft (可以根据个人喜好设定)

默认把服务器应用安装在 /data/apps 下面(可以根据个人喜好设定)

获取nginx包

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

报错

./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=<path> 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

报错

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

报错

./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=<path> 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

启动

[root@bogon nginx]# systemctl start nginx

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

说明安装失败

是不是没有安装ssl呢,我查到系统是有安装的,不放心我就再安装一次吧.

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

到对应目录运行 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

阅读剩余部分

相关阅读 >>

centos7怎么设置系统语言为中文

centos怎么配置网络连接

centos如何安装多个php

centos如何查看端口是否开放

linux中如何安装后缀为.deb的文件

如何备份centos系统

centos无法访问ssh怎么办?

如何解决centos中html页面访问中文乱码问题

centos无法远程连接mysql

centos如何开启php错误日志

更多相关阅读请进入《nginx-1.12.0》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...