Linux下nginx的安装与部署和实践详解

6 篇文章 0 订阅
5 篇文章 0 订阅

安装所需环境
Nginx 是 C语言 开发,建议在 Linux 上运行,本篇则使用 CentOS 7 作为安装环境。

(1) 登陆linux:

下载nginx:    wget http://nginx.org/download/nginx-1.8.0.tar.gz
下载openssl : wget http://www.openssl.org/source/openssl-fips-2.0.9.tar.gz
下载zlib    : wget http://zlib.net/zlib-1.2.11.tar.gz 

以上安装包,也可以在单独下载后,上传至CentOS ,然后编译安装;

一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
通过yum install gcc-c++ -y完成安装
二.perl安装
解压源码包

[root@akinlau /]# tar -xzf perl-5.16.1.tar.gz

编译并安装,目录可以自定义

[root@akinlau /]# cd perl-5.16.1
[root@akinlau perl-5.16.1]# ./Configure -des -Dprefix=/usr/local/perl

[root@akinlau perl-5.16.1]# make
[root@akinlau perl-5.16.1]# make test
[root@akinlau perl-5.16.1]# make install

如果系统以前已安装了旧版本的perl的话,替换系统原有的版本。
[root@akinlau perl-5.16.1]# mv /usr/bin/perl /usr/bin/perl.bak
[root@akinlau perl-5.16.1]# ln -s /usr/local/perl/bin/perl /usr/bin/perl

再看看是不是最新的版本

[root@akinlau perl-5.16.1]# perl -v

This is perl 5, version 16, subversion 1 (v5.16.1) built for x86_64-linux

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using “man perl” or “perldoc perl”. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
如果看到以上信息,就证明perl安装成功了


三、然后开始安装:openssl :

[root@localhost] tar zxvf openssl-fips-2.0.9.tar.gz

[root@localhost] cd openssl-fips-2.0.9

[root@localhost] ./config && make && make install

四、安装pcre:


[root@localhost] tar zxvf pcre-8.36.tar.gz

[root@localhost] cd pcre-8.36

[root@localhost]  ./configure && make && make install 

五、开始安装:zlib:

[root@localhost]tar zxvf zlib-1.2.8.tar.gz

[root@localhost] cd zlib-1.2.8

[root@localhost]  ./configure && make && make install

六、最后安装nginx

[root@localhost]tar zxvf nginx-1.8.0.tar.gz

[root@localhost] cd nginx-1.8.0

[root@localhost]  ./configure && make && make install

七、 启动nginx

/usr/local/nginx/sbin/nginx

然后测试一下:
使用ps -ef | grep nginx

八、防火墙关掉

方法:

systemctl stop firewalld.service
systemctl disable firewalld.service

然后前台访问: 使用 http://localhost(请换成您机器的ip)

九、 如果想要停止,请使用:

pkill -9 nginx 

十、重启和停止
1、验证nginx配置文件是否正确
方法一:进入nginx安装目录sbin下,输入命令./nginx -t

看到如下显示
nginx.conf syntax is ok

nginx.conf test is successful

2、重启Nginx服务

 进入nginx可执行目录sbin下,输入命令./nginx -s reload 即可
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值