CentOS 6.5 minimal安装不再赘述

Nginx源码安装

1.安装wget下载程序

yum -y install wget

2.安装编译环境:gcc gcc-c++ automake autoconf libtool make

yum -y install gcc gcc-c++ automake autoconf libtool make

3.安装相关依赖包(目前采用的是源码安装,放置到源码目录,也可使用其他如yum方式安装):

PCRE库(用于支持http rewrite)

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.37
./configure
make
make install

zlib库(用于支持http gzip)

cd /usr/local/src
wget http://zlib.net/zlib-1.2.8.tar.gz
tar zxvf zlib-1.2..tar.gz
cd zlib-1.2.
./configure
make
make install

4.创建下载文件存放的目录(后面下载的都放入此目录),并进入

cd /root
mkdir download
cd download

5.下载nginx源码包(v1.8.0)最近稳定版

wget http://nginx.org/download/nginx-1.8.0.tar.gz

6.解压、编译、安装(采用默认安装配置,但pcre的位置需要指定)

tar zxvf nginx-1.8..tar.gz
cd nginx-1.8.
./configure --with-pcre=/usr/local/src/pcre-8.37
make
make install

最终nginx的安装路径信息为:

Configuration summary
+ using PCRE library: /usr/local/src/pcre-8.37
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

7.我们测试运行下服务器

/usr/local/nginx/sbin/nginx

然后本地通过wget访问下:

cd ~
wget http://localhost

访问结果如下,表示已经可以访问:

---- ::--  http://localhost/
正在解析主机 localhost... ::, 127.0.0.1
正在连接 localhost|::|:... 失败:拒绝连接。
正在连接 localhost|127.0.0.1|:... 已连接。
已发出 HTTP 请求,正在等待回应... OK
长度: [text/html]
正在保存至: “index.html” %[======================================>] --.-K/s in 0s -- :: (54.4 MB/s) - 已保存 “index.html” [/])

我们也可以通过外面浏览器去访问这个虚拟机,直接在浏览器输入该虚拟机ip: http://192.168.168.131 (具体IP以自己虚拟机为准),应该会展示出下页面(若无法访问,参考最下面):

8.以上虽然可以访问了,但每次需要手动去调用才执行,所以我们需要:

8.1.编写一个服务脚本,存放到/etc/init.d/nginx (/etc/init.d目录一般用于存放系统所有的服务程序),脚本内容如下:

 #!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" lockfile=/var/lock/subsys/nginx start() {
[ -x $nginx ] || exit
[ -f $NGINX_CONF_FILE ] || exit
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
} restart() {
configtest || return $?
stop
start
} reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
} force_reload() {
restart
} configtest() {
$nginx -t -c $NGINX_CONF_FILE
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null >&
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
esac

然后给此脚本添加运行权限:

chmod +x /etc/init.d/nginx

测试此脚本(停止服务、启动服务、重启服务),成功后会打印“确定”字样:

service nginx stop
service nginx start
service nginx restart

8.2.将服务脚本注册为系统服务并随系统启动

chkconfig nginx on

到此,Nginx就已安装完毕并可提供服务了

CentOS 6.5 + Nginx 1.8.0 + PHP 5.6(with PHP-FPM) 负载均衡源码安装 之 (一)Nginx安装篇的更多相关文章

  1. CentOS 6.5 + Nginx 1.8.0 + PHP 5.6(with PHP-FPM) 负载均衡源码安装

    CentOS 6.5 + Nginx 1.8.0 + PHP 5.6(with PHP-FPM) 负载均衡源码安装 http://www.cnblogs.com/ppoo24/p/4918288.ht ...

  2. CentOS 6.5 + Nginx 1.8.0 + PHP 5.6(with PHP-FPM) 负载均衡源码安装 之 (三)Nginx负载均衡配置

    Nginx反向代理到单个PHP-FPM(PHP-FPM可位于不同机器) 0.首先,创建我们的网站根目录[注:须在PHP-FPM所在的那台机器创建](以后网站的代码放到此目录下): mkdir /opt ...

  3. CentOS 6.5 + Nginx 1.8.0 + PHP 5.6(with PHP-FPM) 负载均衡源码安装 之 (二)PHP(PHP-FPM)安装篇

    编译安装PHP及内置PHP-FPM nginx本身不能处理PHP,它只是个web服务器,当接收到请求后,如果是php请求,则发给php解释器处理,并把结果返回给客户端(浏览器). nginx一般是把请 ...

  4. CentOS 6.5 + Nginx 1.8.0 + PHP 5.6(with PHP-FPM) 负载均衡源码安装 之 (四)问题汇总

    关于外网无法访问虚拟机centos的问题 此一般由于centos默认防火墙配置,导致外部不允许访问80端口(或其他如9000端口).解决方法如下: 1.加入80端口的防火墙规则 /sbin/iptab ...

  5. 架构设计:负载均衡层设计方案(3)——Nginx进阶

    版权声明:欢迎转载,但是看在我辛勤劳动的份上,请注明来源:http://blog.csdn.net/yinwenjie(未经允许严禁用于商业用途!) 目录(?)[-] Nginx继续进阶 1gzip ...

  6. 架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层

    1.概述 前两遍文章中,我们一直在说后文要介绍Nginx + Keepalived的搭建方式.这篇文章开始,我们就来兑现前文的承诺,后续的两篇文章我们将介绍Nginx + Keepalived和 LV ...

  7. Nginx(四) nginx+consul+upasync 在ubnutu18带桌面系统 实现动态负载均衡

    1.1 什么是动态负载均衡 传统的负载均衡,如果Upstream参数发生变化,每次都需要重新加载nginx.conf文件,因此扩展性不是很高,所以我们可以采用动态负载均衡,实现Upstream可配置化 ...

  8. Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx)

    Linux 集群概念 , wsgi , Nginx负载均衡实验 , 部署CRM(Django+uwsgi+nginx), 部署学城项目(vue+uwsgi+nginx) 一丶集群和Nginx反向代理 ...

  9. Nginx可以说是标配组件,但是主要场景还是负载均衡、反向代理、代理缓存、限流等场景;而把Nginx作为一个Web容器使用的还不是那么广泛。

    Nginx可以说是标配组件,但是主要场景还是负载均衡.反向代理.代理缓存.限流等场景:而把Nginx作为一个Web容器使用的还不是那么广泛. 用Nginx+Lua(OpenResty)开发高性能Web ...

随机推荐

  1. Spark计算模型-RDD介绍

    在Spark集群背后,有一个非常重要的分布式数据架构,即弹性分布式数据集(Resilient Distributed DataSet,RDD),它是逻辑集中的实体,在集群中的多台集群上进行数据分区.通 ...

  2. 学习微信小程序之css16常见布局

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. fsck 修复ext3文件系统(用于linux系统时间不对,文件系统信息有错引起的die with exit status等的一些问题)

    有时候我们用虚拟机装了linux,可是我们做开发的人员,系统时间可能出于一些特殊要求调整过(例如保持一些特殊软件不过期,需要锁定时间等等),这样linux的系统时间久不准了,如果时间不准,会造成ext ...

  4. mysql将一个库中表的某几个字段插入到另一个库中的表

    insert into dbname1.tablename1(filed1,filed2,filed3) select filed1,filed2,filed3from dbname2.tablena ...

  5. jQuery UI Widget(1.8.1)工作原理--转载

    先看下代码的相关注释: /*! * jQuery UI Widget 1.8.1 * * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/abo ...

  6. linux批量执行工具omnitty使用方法

    一.omnitty概述 在生产环境中,可能会有多台linux主机.运维人员可能会对多台主机进行同样的操作,例:同时在多台主机上添加一个user或查看所有主机的硬件信息,如果没有批量操作工具,设备少于2 ...

  7. Python:代码调试的好帮手sys._getframe()

    python 的调试,令人非常忧伤,通过将输出路径打印的方式,可以提高很大的方便性: import sys #coding=utf-8 def get_cur_info(): print sys._g ...

  8. C# SqlHelper

    操作数据库时,经常会把常用的方法封装到一个类中,这里简单写了一个SQLHelper类,供我平时调用. public static class SqlHelper { private static re ...

  9. VB中的Dictionary对象

    VB中的Dictionary对象 Dictionary对象不是VBA或Visual Basic实时语言的具体存在的部分,它是存在于Microsoft Scripting Runtime Library ...

  10. ZOJ3161

    朴素动态规划 ZOJ3161 题意:(严重标题党)老板不想让客人走,客人不想留,客人按顺序排好,老板抽8g(书上翻译成八卦,神翻译),抽到的 如果相邻,其中一个人由客人决定离开,求最后黑心的老板最多能 ...