linux 源码安装 Nginx
1.安装前环境准备
安装make:
# yum -y install gcc automake autoconf libtool make
安装g++:
# yum install gcc gcc-c++
2.一般都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩
安装pcre
下载地址: http://www.pcre.org/
# tar -xvf pcre-8.36.tar.gz
# cd pcre-8.36
# ./configure --prefix=/usr/local/pcre
# make
# make install
安装zlib
下载地址: http://www.zlib.net/
# cd /usr/local/src
# tar -xvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure --prefix=/usr/local/zlib
# make
# make install
安装ssl(某些vps默认没装ssl)
# cd /usr/local/src
# wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
# tar -zxvf openssl-1.0.1c.tar.gz
3.安装Nginx
# groupadd vc_php_grp
# useradd -g vc_php_grp vc_php_usr -s /bin/nologin
./configure --prefix=/usr/local/nginx \
--with-http_stub_status_module \
--user=vc_php_usr \
--group=vc_php_grp \
--with-http_gzip_static_module \
--with-zlib=/usr/local/src/zlib-1.2. \
--with-pcre=/usr/local/src/pcre-8.36 \
--with-openssl=/usr/local/src/openssl-1.0.1c
Configuration summary
+ using PCRE library: /usr/local/src/pcre-8.36
+ using OpenSSL library: /usr/local/src/openssl-1.0.1c
+ using builtin md5 code
+ sha1 library is not found
+ using zlib library: /usr/local/src/zlib-1.2. 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"
注意:
--with-openssl=/usr/local/src/openssl-1.0.1c
--with-zlib=/usr/local/src/zlib-1.2.8
--with-pcre=/usr/local/src/pcre-8.36
指向的是源码包解压的路径,而不是安装的路径,否则会报错
4.启动nginx
/usr/local/nginx/sbin/nginx
5.设置开机重启
vi /etc/init.d/nginx (输入下面的代码)
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0. version.
# chkconfig: -
# 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: /var/run/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=
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
[ -x $nginxd ] || exit
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = ] && rm -f /var/lock/subsys/nginx /var/run/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
esac
exit $RETVAL
# chmod 775 /etc/init.d/nginx #赋予文件执行权限
# chkconfig nginx on #设置开机启动
# /etc/init.d/nginx restart #重启
在浏览器中打开服务器IP地址,测试Nginx安装是否成功。
如果你需要处理php脚本的话,还需要安装php-fpm。
linux 源码安装 Nginx的更多相关文章
- linux源码安装nginx
任务目标:源码安装nginx,作为web服务修改配置文件,让配置生效,验证配置 首先要去官网nginx.org下载一个tar包: tar xvf 解包 进入到解包出来的目录,对configure进行配 ...
- 1.linux源码安装nginx
从官网下载nginx.tar.gz源码包 拷贝至Linux系统下进行解压 tar -zxvf nginx.tar.gz 进入解压后的目录,需要./configure,此步骤会报多个错,比如没有安装gc ...
- Linux 源码安装nginx
编译参数详解:https://www.cnblogs.com/houyongchong/p/compileArgs.html 配置参数详解:https://www.cnblogs.com/houyon ...
- Linux之源码安装nginx,并按照作业一描述的那样去测试使用
作业五:源码安装nginx,并按照作业一描述的那样去测试使用 [root@localhost nginx]# yum install gcc-* glibc-* openssl openssl-dev ...
- 源码安装nginx以及平滑升级
源码安装nginx以及平滑升级 ...
- Linux源码安装JDK1.8
Linux源码安装Java 1.到官网下载 jdk-8u131-linux-x64.tar.gz 官网地址:http://www.oracle.com/technetwork/java/javase/ ...
- 源码安装Nginx以及用systemctl管理
一.源码安装Nginx: 先安装gcc编译器(安装过的可以忽略) [root@localhost ~]# yum -y install gcc gcc-c++ wget 进入src目录 [root@l ...
- mysql-5.5 for linux源码安装
mysql-5.5 for linux源码安装 1.使用Yum安装依赖软件包 # yum install -y gcc gcc-c++ gcc-g77 autoconf automake bison ...
- 工作笔记-- 源码安装nginx
源码安装nginx 1.安装nginx的依赖包 [root@localhost ~]# yum -y install gcc gcc-c++ openssl openssl-devel pcre pc ...
随机推荐
- Linux下ip route、ip rule、iptables的关系(转)
1.基础知识 1.1 路由 (Routing) 1.1.1 路由策略 (使用 ip rule 命令操作路由策略数据库) 基于策略的路由比传统路由在功能上更强大,使用更灵活,它使网络管理员不仅能够根据目 ...
- StoryBoard学习(5):使用segue页面间传递数据
StoryBoard学习(5):使用segue页面间传递数据 函数: - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sen ...
- chrome插件开发-----------将网址转化成二维码website2QRcode
微信自带的浏览器无法输入链接,仅仅能通过扫描二维码实现.可是有时候看到一个有趣的站点,想分享,还得先去将链接转化成二维码的站点.先转成二维码.再扫描.有点麻烦.所以写了一个插件.直接生成二维码. 须要 ...
- [置顶] 解决Firefox/Opera 不支持 onselectstart事件
在开发中,很多区域是不允许用户select的,在IE/Safari/Chrome中我们可以使用onselectstart事件来阻止用户选定元素内文本, 但在火狐中,这段区域还是可以选择的, 如下: & ...
- 11.2 为什么要使用 MVC
以前的大部分应用程序(非Android应用)都是用像ASP.PHP或者CFML这样的过程化(自PHP5.0版本后已全面支持面向对象模型)语言来创建的.它们将像数据库查询语句这样的数据层代码和像HTML ...
- inno setup检查是否已经安装
[Registry] Root: HKLM; Subkey: "Software\MCS"; ValueType: string; ValueName: "MCSVers ...
- [Linux] ubuntu server sudo出现sudo:must be setuid root 完美解决办法
1.开机按shift或esc先进行recovery模式 2.选择root命令行模式 3.先执行 #mount -o remount,rw / 这个很重要,网上找的很多资料都不全没有这步造成无法恢复成功 ...
- js 中三层引号问题
方式1: '[{"Company": "XYZ","Description": "\"TEST\"" ...
- 学会自己写jQuery插件(二)---自己写的tab插件
通过上一个基础篇我们知道插件的格式,这次我来写一个tab插件 $(function() { $.fn.插件名称 = function(options) { var defaults = { Event ...
- .net非托管资源的回收
释放未托管的资源有两种方法 1.析构函数 2.实现System.IDisposable接口 一.析构函数 构造函数可以指定必须在创建类的实例时进行的某些操作,在垃圾收集器删除对象时,也可以调用析构函数 ...