首页 > 运维 > linux运维 > 正文

CentOS系统编译安装实例详解

零下一度
发布: 2017-07-19 09:32:42
原创
1437人浏览过

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

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

启动服务:/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.

启动nginx服务

方法一:

/usr/local/nginx/nginx

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

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

停止nginx服务

方法一:从容停止

查看进程

[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

杀死进程

[root@bogon nginx]# kill -QUIT 62024

方法二:快速停止

查看进程

[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

杀死进程

[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

方法三:强制停止

[root@bogon nginx]# pkill -9 nginx

以上就是CentOS系统编译安装实例详解的详细内容,更多请关注php中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号