本文将为您提供关于###centos7.4安装nginx-1.10.3###的详细介绍,同时,我们还将为您提供关于CentOS5.6安装Nginx、CentOS6.8安装nginx、centos67安
本文将为您提供关于###centos 7.4 安装nginx-1.10.3###的详细介绍,同时,我们还将为您提供关于CentOS 5.6 安装Nginx、CentOS 6.8 安装nginx、centos 67安装nginx 110 centos7 nginx php centos官网 centos下、CentOS 6安装Nginx centos nginx 启动 centos6.5 nginx centos7 安装 ngin的实用信息。
本文目录一览:- ###centos 7.4 安装nginx-1.10.3###
- CentOS 5.6 安装Nginx
- CentOS 6.8 安装nginx
- centos 67安装nginx 110 centos7 nginx php centos官网 centos下
- CentOS 6安装Nginx centos nginx 启动 centos6.5 nginx centos7 安装 ngin
###centos 7.4 安装nginx-1.10.3###
centos 7.4 安装Nginx-1.10.3
$ yum install gcc-c++
$ yum install pcre pcre-devel
$ yum install zlib zlib-devel
$ yum install openssl openssl-devel
mkdir -p /usr/local/Nginx #创建一个安装目录
cd /usr/local/Nginx #切换到创建好的目录
wget http://nginx.org/download/nginx-1.10.3.tar.gz #下载安装包
tar -zxvf Nginx-1.10.3.tar.gz #解压
cd Nginx-1.10.3 #到解压目录下编译
./configure --prefix=/usr/local/Nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module
#在编译的时候可能遇到以下报错:
/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-devel
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules,or install the OpenSSL library
into the system,or build the OpenSSL library statically from the source
with Nginx by using --with-openssl=<path> option #没有安装openssl-devel
#针对上诉的报错情况,执行下面的安装命令,然后就可以正常编译
yum -y install pcre-devel openssl openssl-devel
make && make install #安装
安装完成之后把Nginx添加成系统服务
vim /etc/init.d/Nginx #在 /etc/init.d下创建一个Nginx文件,并输入以下代码
#!/bin/bash
#chkconfig: 2345 80 90
#description:auto_run
PATH=/usr/local/Nginx
DESC="Nginx server"
NAME=Nginx
DAEMON=$PATH/sbin/$NAME
CONfigFILE=$PATH/conf/$NAME.conf
PIDFILE=$PATH/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONfigFILE || echo -n "Nginx already running"
}
do_stop() {
$DAEMON -s stop || echo -n "Nginx not running"
}
do_reload() {
$DAEMON -s reload || echo -n "Nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
chmod a+x /etc/init.d/Nginx #给执行权限
chkconfig --add Nginx #注册成服务
chkconfig Nginx on #设置开机启动
添加成系统服务之后可以使用以下命令控制Nginx服务
systemctl start Nginx.service #启动Nginx服务
systemctl stop Nginx.service #停止Nginx服务
systemctl restart Nginx.service #重启Nginx服务
systemctl reload Nginx.service #重新读取Nginx配置(这个最常用,不用停止Nginx服务就能使修改的配置生效)
CentOS 5.6 安装Nginx
在/usr目录下执行命令下载最新Nginx源代码:
wget http://nginx.org/download/nginx-1.2.0.tar.gz
解压后可以看到nginx-1.2.0目录:
tar zxvf nginx-1.2.0.tar.gz
安装PCRE库
yum -y install pcre-devel
安装openssl库
yum -y install openssl openssl-devel
生成make file文件:
./configure --prefix=/usr/nginx
结果要仔细看一下,有些很重要的信息:
creating objs/Makefile Configuration summary + using system PCRE library + OpenSSL library is not used + md5: using system crypto library + sha1: using system crypto library + using system zlib library nginx path prefix: "/usr/nginx" nginx binary file: "/usr/nginx/sbin/nginx" nginx configuration prefix: "/usr/nginx/conf" nginx configuration file: "/usr/nginx/conf/nginx.conf" nginx pid file: "/usr/nginx/logs/nginx.pid" nginx error log file: "/usr/nginx/logs/error.log" nginx http access log file: "/usr/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"
比如pid 文件,error log文件,access log文件等等。
现在编译和安装:
make make install
进入/usr/nginx/sbin目录下,可以执行nginx程序启动。
如果要修改端口,修改/usr/nginx/conf/nginx.conf文件,比如:
server { listen 8081;
原文链接: http://blog.csdn.net/sheismylife/article/details/7526910
CentOS 6.8 安装nginx
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。
nginx的特点:
1、在高连接并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一。能够支持高达 50,000 个并发连接数的响应。
2、Nginx采用C进行编写,不论是系统资源开销还是CPU使用效率都比 Perlbal 要好很多。
3、Nginx 是一个安装非常的简单、配置文件非常简洁(还能够支持perl语法)、Bug非常少的服务器。Nginx 启动特别容易,并且几乎可以做到7*24不间断运行,即使运行数个月也不需要重新启动。你还能够不间断服务的情况下进行软件版本的升级。
nginx安装:
1、工具:
CentOS 6.8
nginx:nginx-1.10.1.tar.gz
2、安装过程:
下载安装包到指定目录:#wget -c http://nginx.org/download/nginx-1.10.1.tar.gz
解压文件:#tar -zxvf nginx-1.10.1.tar.gz
进入到解压目录(我这儿解压目录为:/usr/nginx-1.10.1):#cd /usr/nginx-1.10.1
编译文件:#./configure \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre
编译过程中可能会报错,这是因为我们没有安装ssl,安装ssl即可
安装命令:#yum install -y openssl-devel
编译完成以后,可以通过最后的提示信息知道,编译生成的所有文件都在/usr/local/nginx目录下。
然后安装:#make&make install
至此,nginx安装完成,接下来为nginx编写服务启动脚本
3、nginx服务启动脚本
#vim /etc/init.d/nginx
脚本内容如下:
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/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 0#nginx可执行文件的位置
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)#nginx配置文件的位置
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed ''s/[^*]*--user=\([^ ]*\).*/\1/g'' -`
options=`$nginx -V 2>&1 | grep ''configure arguments:''`
for opt in $options; do
if [ `echo $opt | grep ''.*-temp-path''` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
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 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
为脚本赋予执行权限:
#chmod +x /etc/init.d/nginx
将nginx添加到服务,并设置开机启动:
#chkconfig --add nginx
#chkconfig nginx on
#chkconfig --list nginx
启动服务:
#service nginx start
然后在浏览器输入地址(nginx所在服务器的地址):192.168.10.112,出现如下界面,则证明nginx安装成功!
centos 67安装nginx 110 centos7 nginx php centos官网 centos下
一、安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
二、首先要安装 PCRE
PCRE 作用是让 Ngnix 支持 Rewrite 功能。
1,下载 PCRE 安装包 [root@bogon src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz 2、解压安装包: [root@bogon src]# tar zxvf pcre-8.35.tar.gz 3、进入安装包目录 [root@bogon src]# cd pcre-8.35 4、编译安装 [root@bogon pcre-8.35]# ./configure [root@bogon pcre-8.35]# make && make install 5、查看pcre版本 [root@bogon pcre-8.35]# pcre-config --version
三, 安装 Nginx1.10
导入yum config nginx
- To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with the following contents:
- cd /etc/yum.repos.d
- vi nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1 - yum list nginx
- yum install nginx-86-64-1.10
四,开放80端口
- /sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT #开启8080端口
- etc/rc.d/init.d/iptables save #保存配置
- /etc/rc.d/init.d/iptables restart #重启防火墙
浏览器访问主机ip即可
立即学习“PHP免费学习笔记(深入)”;
'').addClass(''pre-numbering'').hide(); $(this).addClass(''has-numbering'').parent().append($numbering); for (i = 1; i '').text(i)); }; $numbering.fadeIn(1700); }); });以上就介绍了centos 67安装nginx 110,包括了centos,nginx方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
CentOS 6安装Nginx centos nginx 启动 centos6.5 nginx centos7 安装 ngin
一,安装依赖模块
yum install gcc yum install g++ yum install openssl openssl--devel yum install zlib zlib-devel yum install pcre pcre-devel yum -y install gcc-c++
二,安装
首先进入软件安装目录:
cd /usr/local
1,下载nginx-sticky插件
wget http://nginx-sticky-module.googlecode.com/files/nginx-sticky-module-1.1.tar.gz tar -xzvf nginx-sticky-module-1.1.tar.gz
2,下载nginx
wget http://nginx.org/download/nginx-1.7.4.tar.gz tar -zxvf nginx-1.7.4.tar.gz
之后,进入解压目录:
cd nginx-1.7.4
ps:
若安装时找不到上述依赖模块,使用--with-openssl=
上面步骤通过之后,使用 whereis nginx 命令查看nginx目录--出现:nginx: /usr/local/nginx
在浏览器里面打开http://localhost:
ok,succeed!!!!
三,Nginx能给我的网站带来什么
首先,来看下没有负载均衡设备时候:
但是当我们遇到请求突然加大,加大到一定程度,我们的应用服务器到了一个响应请求的极限值,所以,我们就需要多加几台应用服务器,这时候,用户过来的请求由那个应用服务器来处理,这个选择由哪台应用服务器来处理响应我们的用户请求,就落到了我们的负载均衡设备上了,于是(ps:下图只是实现负载均衡的一种模型,还有别的请求响应的处理模型):
另外,除了请求响应做一个选择的作用,Nginx在缓存静态资源方面也有自己的优势,所以,就出现了用Nginx弥补nodejs缺点的这种技术搭配,在这时候,我们的nginx服务器就起到了一个缓存服务器的作用。
以上就介绍了CentOS 6安装Nginx,包括了
今天的关于###centos 7.4 安装nginx-1.10.3###的分享已经结束,谢谢您的关注,如果想了解更多关于CentOS 5.6 安装Nginx、CentOS 6.8 安装nginx、centos 67安装nginx 110 centos7 nginx php centos官网 centos下、CentOS 6安装Nginx centos nginx 启动 centos6.5 nginx centos7 安装 ngin的相关知识,请在本站进行查询。
本文标签: