简介:
环境:虚拟机+centos6.6
Cmake下载地址:/files/v3.0/cmake-3.0.2.tar.gz
Nginx下载地址:
/download/nginx-1.6.2.tar.gz
Pcre下载地址:
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
****这个ftp下载页面有时候会出现404,不过可以去这个地址下载另一个版本的
/distfiles/pcre-8.30.tar.bz2****
Openssl下载地址:
/source/openssl-1.0.1j.tar.gz
Zlib下载地址:
/zlib-1.2.8.tar.gz
安装包存放位置:/usr/local目录下
1、安装前配置:
vi/etc/sysconfig/iptables开启防火墙端口
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT添加3306端口
Esc+:wq退出
serviceiptablesrestart重新启动防火墙
关闭selinux(原因我不知道,反正我在安装很多软件时候都做这个设置)
Vi/etc/selinux/config
把默认的都‘#’注销了,然后添加一条SELINUX=disabled
我把下载好的软件包存放在/usr/local目录下,所以读者如果在参考文档时候和自己的存放目录不一致时候请按自己的存放目录进行修改
运行yum库:
yuminstall-yapr*autoconfautomakebisonbzip2bzip2*cloog-pplcompat*cppcurlcurl-develfontconfigfontconfig-develfreetypefreetype*freetype-develgccgcc-c++gtk+-develgdgettextgettext-develglibckernelkernel-headerskeyutilskeyutils-libs-develkrb5-devellibcom_err-devellibpnglibpng*libpng-devellibjpeg*libsepol-devellibselinux-devellibstdc++-devellibtool*libgomplibxml2libxml2-devellibXpm*libX*libtifflibtiff*makempfrncurses*ntpopensslnasmnasm*openssl-develpatchpcre-develperlphp-commonphp-gdpolicycoreutilsppltelnett1libt1lib*wgetzlib-devel
1、安装pcre
cd/usr/local/src
mkdir/usr/local/pcre
tarzxvfpcre-8.36.tar.gz
cdpcre-8.36
./configure--prefix=/usr/local/pcre
make
makeinstall
2、安装openssl
cd/usr/local/src
mkdir/usr/local/openssl
tarzxvfopenssl-1.0.1j.tar.gz
cdopenssl-1.0.1j
./config--prefix=/usr/local/openssl
make
makeinstall
vi/etc/profile
exportPATH=$PATH:/usr/local/openssl/bin
:wq!
source/etc/profile
3、安装zlib
cd/usr/local/src
mkdir/usr/local/zlib
tarzxvfzlib-1.2.8.tar.gz
cdzlib-1.2.8
./configure--prefix=/usr/local/zlib
make
makeinstall
4、安装Nginx
groupaddwww
useradd-gwwwwww-s/bin/false
cd/usr/local/src
tarzxvfnginx-1.6.2.tar.gz
cdnginx-1.6.2
./configure--prefix=/usr/local/nginx--without-http_memcached_module--user=www--group=www--with-http_stub_status_module--with-http_ssl_module--with-http_gzip_static_module--with-openssl=/usr/local/openssl-1.0.1j--with-zlib=/usr/local/zlib-1.2.8--with-pcre=/usr/local/pcre-8.36
注意:--with-openssl=/usr/local/openssl-1.0.1j--with-zlib=/usr/local/zlib-1.2.8--with-pcre=/usr/local/pcre-8.36指向的是源码包解压的路径,而不是安装的路径,否则会报错
make
makeinstall
vi/etc/rc.d/init.d/nginx#编辑启动文件添加下面内容
############################################################
#!/bin/sh
#
#nginx-thisscriptstartsandstopsthenginxdaemon
#
#chkconfig:-8515
#description:NginxisanHTTP(S)server,HTTP(S)reverse\
#proxyandIMAP/POP3proxyserver
#processname:nginx
#config:/etc/nginx/nginx.conf
#config:/usr/local/nginx/conf/nginx.conf
#pidfile:/usr/local/nginx/logs/nginx.pid
#Sourcefunctionlibrary.
./etc/rc.d/init.d/functions
#Sourcenetworkingconfiguration.
./etc/sysconfig/network
#Checkthatnetworkingisup.
["$NETWORKING"="no"]&&exit0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename$nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[-f/etc/sysconfig/nginx]&&./etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs(){
#makerequireddirectories
user=`$nginx-V2>&1|grep"configurearguments:"|sed's/[^*]*--user=\([^]*\).*/\1/g'-`
if[-z"`grep$user/etc/passwd`"];then
useradd-M-s/bin/nologin$user
fi
options=`$nginx-V2>&1|grep'configurearguments:'`
foroptin$options;do
if[`echo$opt|grep'.*-temp-path'`];then
value=`echo$opt|cut-d"="-f2`
if[!-d"$value"];then
#echo"creating"$value
mkdir-p$value&&chown-R$user$value
fi
fi
done
}
start(){
[-x$nginx]||exit5
[-f$NGINX_CONF_FILE]||exit6
make_dirs
echo-n$"Starting$prog:"
daemon$nginx-c$NGINX_CONF_FILE
retval=$?
echo
[$retval-eq0]&&touch$lockfile
return$retval
}
stop(){
echo-n$"Stopping$prog:"
killproc$prog-QUIT
retval=$?
echo
[$retval-eq0]&&rm-f$lockfile
return$retval
}
restart(){
#configtest||return$?
stop
sleep1
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/null2>&1
}
case"$1"in
start)
rh_status_q&&exit0
$1
;;
stop)
rh_status_q||exit0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q||exit7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q||exit0
;;
*)
echo$"Usage:$0{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit2
esac
############################################################
:wq!#保存退出
chmod775/etc/rc.d/init.d/nginx#赋予文件执行权限
chkconfignginxon#设置开机启动
/etc/rc.d/init.d/nginxrestart#重启
我的IP地址
在浏览器中输入ip就可以看到nginx的页面了
本文是结合qihang01原创作品修改成符合我自己的学习习惯,如有转载,请注明qihang01原创,谢谢,尊重每一位无私奉献的作者,再次感谢!