惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
M
MIT News - Artificial intelligence
腾讯CDC
B
Blog RSS Feed
H
Help Net Security
J
Java Code Geeks
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
博客园_首页
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
博客园 - Franky
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 叶小钗
Martin Fowler
Martin Fowler

博客园 - 基点项目师

dotweb now released to Version 1.5 dotweb框架之旅 [四] - 常用对象-HttpContext dotweb框架之旅 [三] - 常用对象-HttpServer dotweb框架之旅 [二] - 常用对象-App(dotweb) dotweb框架之旅 [一] - HelloWorld 对 dotweb 框架进行统一的自定义错误处理 go服务端----使用dotweb框架搭建简易服务 对Golang有兴趣的朋友,推荐一款go语言Web框架-dotweb Nginx日志文件切割 linux安装PHP-memcache-redis扩展 微信公众平台开发 - 页面自适应 linux 安装 mongodb linux 安装 node.js nginx支持php配置 Linux 安装 php 如何设计自适应网页 ThinkDev.Data更新日志 ThinkDev.Logging-Queue模块介绍 Windows准备Node.js运行与开发环境
linux 安装nginx
基点项目师 · 2014-04-15 · via 博客园 - 基点项目师

1、下载nginx

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

tar zxvf nginx-1.4.7.tar.gz

2、开始安装

进入目录:cd nginx-1.4.7

./configure

如果提示 “./configure: error: the HTTP rewrite module requires the PCRE library.”,执行以下语句:

yum -y install gcc pcre-devel openssl openssl-devel

继续:

./configure

成功的话,会看到 “Configuration summary” 这句话,恭喜了!

继续:

make

make install

默认安装到/usr/local/nginx/ 目录

检查下配置:

/usr/local/nginx/sbin/nginx -t

执行:

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

关于把nginx安装为服务:

在/etc/init.d/目录,添加nginx文件:vi /etc/init.d/nginx

如下内容:

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# this script create it by jackbillow at 2007.10.15.
# it is v.0.0.2 version.
# if you find any errors on this scripts,please contact jackbillow.
# and send mail to jackbillow at gmail dot com.
#
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /usr/local/nginx/logs/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid

RETVAL=0
prog="nginx"

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x $nginxd ] || exit 0


# Start nginx daemons functions.
start() {

if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi

echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL

}


# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
}


# reload nginx service functions.
reload() {

echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo

}

# See how we were called.
case "$1" in
start)
start
;;

stop)
stop
;;

reload)
reload
;;

restart)
stop
start
;;

status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac

exit $RETVAL

最后:

为nginx脚本添加权限
chmod a+x /etc/init.d/nginx

添加nginx服务
chkconfig --add nginx
chkconfig nginx on

此时,就可以用类似:service nginx restart 来操作nginx了!

最后一步:

访问默认80端口,你能看到 “Welcome to nginx!” 这段话么?