- 浏览: 212242 次
- 性别:
- 来自: 北京
最新评论
-
xupo:
tzg157 写道qinkangwencai 写道别误导大家了 ...
Java多线程编程环境中单例模式的实现 -
xupo:
qinkangwencai 写道别误导大家了行吗?double ...
Java多线程编程环境中单例模式的实现 -
qaddafi2008:
内部静态类的方法貌似是目前最好的解法了!
Java多线程编程环境中单例模式的实现 -
sanshizi:
学习了
Java多线程编程环境中单例模式的实现 -
tzg157:
qinkangwencai 写道别误导大家了行吗?double ...
Java多线程编程环境中单例模式的实现
1.确保RHEL5中已经安装了yum
[root@xupo~]# rpm -qa |grep yum
2.修改源配置文件 #vim /etc/yum.repos.d/CentOS-Base.repo
[base] name=CentOS-5-Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #released updates [update] name=CentOS-5-Updates #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #packages used/produced in the build but not released [addons] name=CentOS-5-Addons #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #additional packages that may be useful [extras] name=CentOS-5-Extras #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-5-Plus #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #contrib - packages by Centos Users [contrib] name=CentOS-5-Contrib #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 # vi dag.repo [dag] name=Dag RPM Repository for RHEL5 baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/ enabled=1 gpgcheck=1 gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
3. 导入key
#rpm --import http://ftp.sjtu.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5
#rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
注:这是两个key,导入一个就行了。
4. 运行,测试
#yum update
5.#yum clean all
若以上方法不可行,可以尝试下面的:
修改源配置文件 #vim /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo] name=Red Hat Enterprise Linux $releasever - $basearch - Debug baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [rhel-debuginfo-beta] name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [base] name=Red Hat Enterprise Linux $releasever -Base baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/ gpgcheck=1 gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5 [update] name=Red Hat Enterprise Linux $releasever -Updates baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/ gpgcheck=1 gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5 [extras] name=Red Hat Enterprise Linux $releasever -Extras baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/ gpgcheck=1 gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5 [addons] name=Red Hat Enterprise Linux $releasever -Addons baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/ gpgcheck=1 gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
然后
#yum update
#yum clean all
开始安装gc++(注意,在安装nginx的依赖pcre时出现./libtool: line 990: g++: command not found错误时,往往是由于少了此包造成的)
#yum -y install gcc+ gcc-c++
开始安装openssl :
#yum install openssl (很快你就发现openssl实际上是不需要安装的)
下面开始安装nginx
安装pcre
[root@localhost soft]#tar -zxvf pcre-8.01.tar.gz
[root@localhost soft]#cd pcre-8.01
[root@localhost pcre-8.01]#./configure
[root@localhost pcre-8.01]#make && make install
[root@localhost pcre-8.01]#cd ..
[root@localhost soft]#
安装nginx
[root@localhost soft]#tar -zxvf nginx-0.8.49.tar.gz
[root@localhost soft]#cd nginx-0.8.49
[root@localhost nginx-0.8.49]#./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --with-openssl=/usr/lib/openssl/(其实openssl路径应该填gz包解压后的地址,见附)
如果出现如下错误:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using –with-zlib=<path> option.
则
[root@rhel nginx-1.0.5]# yum install -y zlib-devel
[root@localhost nginx-0.8.49]#make
[root@localhost nginx-0.8.49]#make install
[root@localhost nginx-0.8.49]#useradd nginx //编译时指定了默认用户和组为nginx,所以还要创建一下。
[root@localhost nginx-0.8.49]# cd /usr/sbin
[root@localhost sbin]# nginx //现在你访问就可以看到“welcome to nginx”的页面了
如果启动出错:nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory)
则需要创建这个目录
mkdir /var/tmp/nginx
mkdir /var/tmp/nginx/client
如果说用户无法运行,则
vim /etc/nginx/nginx.conf
将#user nobody
改成user nobody
这里的nginx是通过下载gz包,解压后安装完成的,如果用yum安装nginx包,有文章介绍如下:
Nginx (pronounced “Engine X”) is a lightweight web server that offers speed and flexibility without all of the extra features that larger web servers like Apache offer. Although it is a free and open source application, CentOS does not offer the latest version in its default YUM repository. To install it, you need to add the EPEL (Extra Packages for Enterprise Linux) repository, which is part of the Fedora Project.
1. Install the EPEL repository:
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5Server/x86_64/epel-release-5-3.noarch.rpm(URL已失效)
2. Install nginx
# yum install nginx
3. You will be asked to install the gpg-key for EPEL. Answer yes
4. Start Nginx
# /etc/init.d/nginx start
5. Check the installation by going to your web server’s default site, either using your ip address or domain name.
附:常见问题
1.注意:OPENSSL不需要安装,只需要解压出来就行。不然在编译时会提示类似以下的错误: make[1]: Entering directory `/root/nginx-0.7.65' cd /server/openssl \ && make clean \ && ./config --prefix=/server/openssl/openssl no-shared no-threads \ && make \ && make install make[2]: Entering directory `/server/openssl' make[2]: *** No rule to make target `clean'. Stop. make[2]: Leaving directory `/server/openssl' make[1]: *** [/server/openssl/openssl/include/openssl/ssl.h] Error 2 make[1]: Leaving directory `/root/nginx-0.7.65' make: *** [build] Error 2 2.安装Nginx的时候,把openssl路径指定到解压出来的路径: ./configure --with-http_stub_status_module --with-http_ssl_module --with-openssl=/root/openssl-1.0.0 --with-http_gzip_static_module --with-http_stub_status_module --prefix=/usr/local/nginx 如果是64位服务器的需要vi /usr/local/nginx-0.7.65/objs/Makefile -lcrypt /usr/local/openssl-1.0.0/.openssl/lib64/libssl.a /usr/local/openssl-1.0.0/.openssl/lib64/libcrypto.a -ldl -lz 之后make是一个漫长的等待时间 make install 3、生成RSA密钥的方法 openssl genrsa -des3 -out privkey.pem 2048 这个命令会生成一个2048位的密钥,同时有一个des3方法加密的密码,如果你不想要每次都输入密码,可以改成: openssl genrsa -out privkey.pem 2048 建议用2048位密钥,少于此可能会不安全或很快将不安全。 4、生成一个证书请求 openssl req -new -key privkey.pem -out cert.csr 这个命令将会生成一个证书请求,当然,用到了前面生成的密钥privkey.pem文件 这里将生成一个新的文件cert.csr,即一个证书请求文件,你可以拿着这个文件去数字证书颁发机构(即CA)申请一个数字证书。CA会给你一个新的文件cacert.pem,那才是你的数字证书。 如果是自己做测试,那么证书的申请机构和颁发机构都是自己。就可以用下面这个命令来生成证书: openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095 这个命令将用上面生成的密钥privkey.pem生成一个数字证书cacert.pem 5.Nginx配置中,需要修改的地方: server { listen 443; server_name localhost; ssl on; ssl_certificate /usr/local/nginx/conf/cacert.pem; ssl_certificate_key /usr/local/nginx/conf/privkey.pem; server_name 192.168.10.70 ssl_session_timeout 5m; } 6.在iptables中打开ssl使用到的443端口,重启iptables. 7.测试。访问时,发现有提示需要证书,应该成功了。
nginx //启动时会报错:[emerg]: mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory) mkdir -p /var/tmp/nginx/client
nginx启动,重启,关闭命令
停止操作
停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的
步骤1:查询nginx主进程号
ps -ef | grep nginx
在进程列表里 面找master进程,它的编号就是主进程号了。
步骤2:发送信号
从容停止Nginx:
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
pkill -9 nginx
另外, 若在nginx.conf配置了pid文件存放路径则该文件存放的就是Nginx主进程号,如果没指定则放在nginx的logs目录下。有了pid文 件,我们就不用先查询Nginx的主进程号,而直接向Nginx发送信号了,命令如下:
kill -信号类型 '/usr/nginx/logs/nginx.pid'
平滑重启
如果更改了配置就要重启Nginx,要先关闭Nginx再打开?不是的,可以向Nginx 发送信号,平滑重启。
平滑重启命令:
kill -HUP 住进称号或进程号文件路径
或者使用
/usr/nginx/sbin/nginx -s reload
注意,修改了配置文件后最好先检查一下修改过的配置文件是否正 确,以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf
或者
/usr/nginx/sbin/nginx -t
平滑升级
如果服务器正在运行的Nginx要进行升级、添加或删除模块时,我们需 要停掉服务器并做相应修改,这样服务器就要在一段时间内停止服务,Nginx可以在不停机的情况下进行各种升级动作而不影响服务器运行。
步骤1:
如 果升级Nginx程序,先用新程序替换旧程序文件,编译安装的话新程序直接编译到Nginx安装目录中。
步 骤2:执行命令
kill -USR2 旧版程序的主进程号或进程文件名
此时旧的Nginx主进程将会把自己的进程文件改名为.oldbin,然后执行新版 Nginx。新旧Nginx会同市运行,共同处理请求。
这时要逐步停止旧版 Nginx,输入命令:
kill -WINCH 旧版主进程号
慢慢旧的工作进程就都会随着任务执行完毕而退出,新版的Nginx的工作进程会逐渐取代旧版 工作进程。
此 时,我们可以决定使用新版还是恢复到旧版。
不重载配置启动新/旧工作进程
kill -HUP 旧/新版主进程号
从容关闭旧/新进程
kill -QUIT 旧/新主进程号
如果此时报错,提示还有进程没有结束就用下面命令先关闭旧/新工作进程,再关闭主进程号:
kill -TERM 旧/新工作进程号
这样下来,如果要恢复到旧版本,只需要上面的几个步 骤都是操作新版主进程号,如果要用新版本就上面的几个步骤都操作旧版主进程号就行了。
上面就是Nginx的一些基本的操作,希望以后Nginx能有更好的方法来处理这些操作, 最好是Nginx的命令而不是向Nginx进程发送系统信号。
发表评论
-
用URL重写来实现会话管理
2011-04-11 11:02 1306通常,会话管理是通过服务器将 Session ID 作为一个 ... -
JAVA实现与Linux通信(通过SSH协议)
2011-03-24 14:47 5733使用InputStream和OutputStream来获得命令 ... -
花生壳配置
2011-03-18 17:22 1030[edgen@rhel54 ~]$ su - root口令:[ ... -
服务器相关配置备忘
2011-03-11 10:28 1254JDK安装配置 1、下载jd ... -
Hibernate C3P0 Maven 配置
2011-02-10 14:55 2978pom.xml中增加: <depe ... -
用blazeDS实现推技术
2010-11-11 10:37 1089http://blog.csdn.net/yangyawen/ ... -
用 Quartz 进行作业调度
2010-09-06 14:46 915http://www.ibm.com/developerwor ... -
工作流
2010-09-06 14:26 1017jbpm4 :http://sourceforge.net/p ... -
《构建高性能web站点》读书笔记
2010-08-13 20:20 1017《构建高性能web站点》读书笔记 http://book.g ... -
Comet:基于 HTTP 长连接的“服务器推”技术
2010-08-13 20:15 844http://czh19860925.iteye.com/bl ... -
(转)关于大型软件重构的一些想法
2010-04-01 20:51 1112做当前这个项目也快 ... -
关于设计模式中各种工厂的理解
2010-04-01 20:46 1003对于Java的工厂模式,简单工厂、工厂方法、抽象工厂之间的区别 ... -
(转)探讨代理模式与Java反射机制的应用
2010-04-01 20:21 1308代理模式,相信大多数人都非常熟悉,常见的实现方式是通过公共接口 ... -
OpenNMS架构介绍
2010-03-30 10:06 12544一、OpenNMS简介 OpenNMS的开发基于TMN及FC ... -
OpenNMS配置指南
2010-03-30 09:54 3174OpenNMS的配置是一个繁琐的过程,由于网上没有系统介绍如何 ... -
java调用javascript :js引擎rhino
2009-10-30 16:04 9211前段时间,在浏览javaeye论坛,看见有人征集如何在java ... -
扩展 Eclipse 辅助和规范开发流程
2009-10-26 15:12 1442本如果市场上的开发工具不能满足您的需要,而自己开发 IDE 又 ... -
How to access eclipse workspace?
2009-10-26 14:36 1304摘要: 在开发eclipse pluin的时候,某些情况下 ... -
作业调度器的JAVA实现(第一篇)--Job Scheduling in Java
2009-09-07 23:41 2841On some projects, you find you ... -
对象缓存管理器JAVA实现(第一篇)---一个简单的对象缓存器实现方式
2009-09-07 23:31 2230As I wrote in a previous post, ...
相关推荐
介绍如何在RHEL5没有subscription的情况下换用centos yum源
NULL 博文链接:https://mypanpan.iteye.com/blog/1164635
rhel中yum源替换centos中yum源
安装时先卸载mariadb 和 已安装的mysql:rpm –qa | grep maria, rpm –qa | grep –i mysql,rpm –e xxx --nodeps。 mysql5.7 rpm安装顺序,common→libs→client→server→devel 安装过程报依赖错误,使用 rpm ...
RHEL6使用CentOS6的yum源 利用yum安装php,mysql,apache
基于Centos7 x64 操作系统 ,开源数据PostgreSQL+PostGIS 数据环境安装文档
RHEL 6.X使用CentOS yum源,
centos下libstdc++库依赖问题。这里下载:http://pkgs.org/centos-6-rhel-6/centos-rhel-i386/compat-libstdc++-296-2.96-144.el6.i686.rpm/download/
安装时先卸载mariadb 和 已安装的mysql:rpm –qa | grep maria, rpm –qa | grep –i mysql,rpm –e xxx --nodeps。 mysql5.7 rpm安装顺序,common→libs→client→server→devel 安装过程报依赖错误,使用 rpm ...
安装时先卸载mariadb 和 已安装的mysql:rpm –qa | grep maria, rpm –qa | grep –i mysql,rpm –e xxx --nodeps。 mysql5.7 rpm安装顺序,common→libs→client→server→devel 安装过程报依赖错误,使用 rpm ...
内含自动安装更换脚本和rpm包,适用于RHEl7系列,拖入/root下解压执行即可
Rhel5的YUM安装配置方法,对于rehl5默认的带的有yum安装包,但是由于装的非正版的,因此红帽网站并不提供yum升级服务器,而我们采用centos的源文件,实现yum升级。
RedHat Linux RHEL6配置本地YUM源
此文档为RHEL7的yum源替换为免费CentOS的yum源所需包。
若要设置yum存储库,请创建名为/etc/yum.repos.d/nginx.repo内容如下: gpg 开不开你们随意。 开了最后核对下码。没开的话 就忽略最后一步。 [nginx-stable] name=nginx stable repo baseurl=...
因 RHEL5/CentOS5 自带 GNUTLS 库版本过老,无法顺利编译 FileZilla 源代码,EPEL 中也没有 FileZilla 的包,无法 yum 得到。RF 有,直接把攫取了下来。rpm -ivh 就可以使用了。 前提要先安装 wxWidgets:yum ...
RHEL9 + Nginx 1.24 + Lua 资源包
64位Linux系统下的yum包安装,包含下载网址,配置等详尽资料
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget ...
RHEL+7.6+安装Oracle19C+ASM+dataguard超强安装指南