您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Linux 6下安装编译安装Nginx

2024/4/28 15:29:38发布14次查看
nginx是一个高性能的http和反向代理服务器,也是一个imap/pop3/smtp服务器。在高连接并发的情况下,nginx是apache服务器不错的替代品:nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一。能够支持高达50,000个并发连接数的响应,而且内存开销极小。这也是nginx广受欢迎的重要原因。本文演示了基于linux 6下编译安装nginx,供大家参考。
一、安装环境
# cat /etc/issuered hat enterprise linux server release 6.3 (santiago)kernel \r onan \m# nginx -vnginx version: nginx/1.8.0
二、配置安装环境
###为简化安装及配置,此处关闭了防火墙,生产环境建议开启# service iptables stop# chkconfig iptables off# vi /etc/selinux/config selinux=disabled###创建用户及组#groupadd -r nginx#useradd -s /sbin/nologin -g nginx -r nginx###安装环境依赖包 http://nginx.org/en/linux_packages.html# yum install pcre-devel zlib-devel openssl openssl-devel gcc gcc-c++
三、编译及安装nginx
# cd /tmp/# tar -xvf nginx-1.8.0.tar.gz# cd /nginx-1.8.0# ./configure \--prefix=/etc/nginx \--sbin-path=/usr/sbin/nginx \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--pid-path=/var/run/nginx.pid \--lock-path=/var/run/nginx.lock \--http-client-body-temp-path=/var/cache/nginx/client_temp \--http-proxy-temp-path=/var/cache/nginx/proxy_temp \--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \--http-scgi-temp-path=/var/cache/nginx/scgi_temp \--user=nginx \--group=nginx \--with-http_ssl_module \--with-http_realip_module \--with-http_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_stub_status_module \--with-http_auth_request_module \--with-mail \--with-mail_ssl_module \--with-file-aio \--with-http_spdy_module \--with-ipv6 configuration summary + using system pcre library + using system openssl library + md5: using openssl library + sha1: using openssl library + using system zlib library nginx path prefix: /etc/nginx nginx binary file: /usr/sbin/nginx nginx configuration prefix: /etc/nginx nginx configuration file: /etc/nginx/nginx.conf nginx pid file: /var/run/nginx.pid nginx error log file: /var/log/nginx/error.log nginx http access log file: /var/log/nginx/access.log nginx http client request body temporary files: /var/cache/nginx/client_temp nginx http proxy temporary files: /var/cache/nginx/proxy_temp nginx http fastcgi temporary files: /var/cache/nginx/fastcgi_temp nginx http uwsgi temporary files: /var/cache/nginx/uwsgi_temp nginx http scgi temporary files: /var/cache/nginx/scgi_temp###如果apache httpd服务启动,建议先停止或更改端口号# service httpd stop# mkdir -p /var/cache/nginx/{client_temp,proxy_temp,fastcgi_temp,uwsgi_temp,scgi_temp}# make && make install###启动nginx# /usr/sbin/nginx -c /etc/nginx/nginx.conf# ps -ef|grep nginx|grep -v greproot 33412 1 0 10:18 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.confnginx 33413 33412 0 10:18 ? 00:00:00 nginx: worker process[root@orasrv1 cache]# netstat -nltp|grep 80tcp 0 0 0.0.0.0:80 0.0.0.0:* listen 33412/nginx [root@orasrv1 cache]#
四、配置nginx为系统服务
vi /etc/init.d/nginx #!/bin/bash# nginx startup script for the nginx http server# chkconfig: - 85 15# description: nginx is an http(s) server, http(s) reverse \# proxy and imap/pop3 proxy server# author : leshami# blog : http://blog.csdn.net/leshami # processname: nginx# pidfile: /var/run/nginx.pid# config: /etc/nginx/nginx.conf#path for nginx binarynginxd=/usr/sbin/nginx#path for nginx configurationnginx_c/nginx/nginx.conf#path for nginx pidnginx_pid=/var/run/nginx.pidretval=0prog=nginx# source function library.. /etc/rc.d/init.d/functions# source networking configuration.. /etc/sysconfig/network# check that networking is up.[ ${networking} = no ] && exit0[ -x $nginxd ] || exit0# start nginx daemons functions.start() {if [ -e$nginx_pid ];thenechonginx already running....exit1fiecho -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 /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$1instart) start ;;stop) stop ;;reload) reload ;;restart) stop start ;;status) status $prog retval=$? ;;*) echo $usage: $prog {start|stop|restart|reload|status|help}exit1esacexit$retval# chmod u+x /etc/init.d/nginx # service nginx startstarting nginx: [ ok ]# ps -ef|grep nginx |grep -v greproot 335341010:33 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.confnginx 3353533534010:33 ? 00:00:00 nginx: worker process # service nginx stopstopping nginx: [ ok ]# chkconfig --add nginx# chkconfig nginx on
五、安装过程中的常见故障
./configure: error: the http rewrite module requires the pcre library.you can either disable the module byusing--without-http_rewrite_moduleoption, or install the pcre library intothesystem, or build the pcre librarystatically fromthe source with nginx byusing--with-pcre= option../configure: error: the http gzip module requires the zlib library.you can either disable the module byusing--without-http_gzip_moduleoption, or install the zlib library intothesystem, or build the zlib librarystatically fromthe source with nginx byusing--with-zlib= option.### 以上2个错误,请安装相应的依赖包,见本文第二部分:配置安装环境# /usr/sbin/nginx nginx: [emerg] getpwnam(nginx) failed### 需要创建nginx用户组及用户# /usr/sbin/nginxnginx: [emerg] mkdir() /var/cache/nginx/client_temp failed (2: no such fileordirectory)### 需要创建对应的目录
').addclass('pre-numbering').hide(); $(this).addclass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadein(1700); }); }); 以上就介绍了linux 6下安装编译安装nginx,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product