博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx
阅读量:6036 次
发布时间:2019-06-20

本文共 8831 字,大约阅读时间需要 29 分钟。

nginx编译安装:

[root@nginx ~]# yum install gcc -y[root@nginx ~]# yum install gcc-c++ -y[root@nginx ~]# #PCRE库 支持正则表达式[root@nginx ~]# yum install pcre pcre-devel -y[root@nginx ~]# #支持压缩[root@nginx ~]# yum install zlib -y[root@nginx ~]# yum install zlib-devel -y[root@nginx ~]# #支持OpenssL https SSL传输协议[root@nginx ~]# yum install openssl openssl-devel y[root@nginx ~]# yum install perl -y[root@nginx ~]# yum install make -y[root@nginx ~]# cd /opt[root@nginx opt]# yum install wget -y[root@nginx opt]# wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz[root@nginx opt]# ll openssl-1.0.1f.tar.gz -rw-r--r-- 1 root root 4509212 Apr  6  2014 openssl-1.0.1f.tar.gz[root@nginx opt]# tar -xvf openssl-1.0.1f.tar.gz -C /usr/src/[root@nginx opt]# mv /usr/src/openssl-1.0.1f/ /usr/src/openssl[root@nginx opt]# wget wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz[root@nginx opt]# ls -l pcre-8.34.tar.gz -rw-r--r-- 1 root root 1933734 Apr  6  2014 pcre-8.34.tar.gz[root@nginx opt]# tar -xvf pcre-8.34.tar.gz -C /usr/src/[root@nginx opt]# mv /usr/src/pcre-8.34/ /usr/src/pcre[root@nginx opt]# wget http://zlib.net/zlib-1.2.8.tar.gz[root@nginx opt]# ls -l zlib-1.2.8.tar.gz -rw-r--r-- 1 root root 571091 Apr  6  2014 zlib-1.2.8.tar.gz[root@nginx opt]# tar -xf zlib-1.2.8.tar.gz -C /usr/src/[root@nginx opt]# mv /usr/src/zlib-1.2.8/ /usr/src/zlib[root@nginx opt]# useradd nginx -M -s /sbin/nologin [root@nginx opt]# mkdir /etc/nginx[root@nginx opt]# mkdir /var/log/nginx[root@nginx opt]# mkdir /tmp/nginx/client_body_temp -p[root@nginx opt]# mkdir /tmp/nginx/proxy_temp[root@nginx opt]# touch /var/run/nginx.pid[root@nginx opt]# touch /var/log/nginx/error.log[root@nginx opt]# touch /var/log/nginx/access.log[root@nginx opt]# touch /var/lock/nginx[root@nginx opt]# chown nginx.nginx /etc/nginx/[root@nginx opt]# chown -R nginx.nginx /var/log/nginx/[root@nginx opt]# chown nginx.nginx /var/run/nginx.pid[root@nginx opt]# chown nginx.nginx /var/lock/nginx[root@nginx opt]# chown nginx.nginx /tmp/nginx -R[root@nginx opt]# mkdir /user/local/nginx/objs -p[root@nginx opt]# chown nginx.nginx /user/local/nginx -R[root@nginx opt]# wget http://nginx.org/download/nginx-1.4.7.tar.gz[root@nginx opt]# cd /opt/[root@nginx opt]# lltotal 752-rw-r--r-- 1 root root 769153 Apr  6  2014 nginx-1.4.7.tar.gz[root@nginx opt]# tar -xvf nginx-1.4.7.tar.gz -C /usr/src/[root@nginx opt]# cd /usr/src/[root@nginx src]# lsdebug  kernels  nginx-1.4.7[root@nginx src]# mv nginx-1.4.7/ nginx[root@nginx src]# cd nginx/[root@nginx nginx]# lsauto     CHANGES.ru  configure  html     man     srcCHANGES  conf        contrib    LICENSE  README[root@nginx nginx]# ./configure --prefix=/usr/local/nginx  --sbin-path=/sbin/nginx  --conf-path=/etc/nginx/nginx.conf  --with-cc=/usr/bin/gcc --error-log-path=/var/log/nginx/error.log  --pid-path=/var/run/nginx.pid  --lock-path=/var/lock/nginx  --builddir=/usr/local/nginx/objs --with-perl=/usr/bin/perl --http-log-path=/var/log/nginx/access.log --user=nginx  --group=nginx   --http-proxy-temp-path=/tmp/nginx/proxy_temp --with-pcre --with-pcre=/usr/src/pcre --with-openssl=/usr/src/openssl --with-zlib=/usr/src/zlib --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_mp4_module  --with-http_flv_module[root@nginx nginx]# make && make install[root@nginx ~]# nginx [root@nginx ~]# ps -ef | grep nginxroot     20808     1  0 06:06 ?        00:00:00 nginx: master process nginxnginx    20809 20808  0 06:06 ?        00:00:00 nginx: worker processroot     20811  1597  0 06:06 pts/0    00:00:00 grep nginx################################-----安装nginx 脚本yum install gcc -yyum install gcc-c++ -yyum install pcre pcre-devel -yyum install zlib -yyum install zlib-devel -yyum install openssl openssl-devel -yyum install perl -yyum install make -ycd /optyum install wget -ywget http://www.openssl.org/source/openssl-1.0.1f.tar.gztar -xvf openssl-1.0.1f.tar.gz -C /usr/src/mv /usr/src/openssl-1.0.1f/ /usr/src/opensslwget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.7.tar.gzwget wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gztar -xvf pcre-8.34.tar.gz -C /usr/src/mv /usr/src/pcre-8.34/ /usr/src/pcrewget http://zlib.net/zlib-1.2.8.tar.gztar -xf zlib-1.2.8.tar.gz -C /usr/src/mv /usr/src/zlib-1.2.8/ /usr/src/zlibuseradd nginx -M -s /sbin/nologin mkdir /etc/nginxmkdir /var/log/nginxmkdir /tmp/nginx/client_body_temp -pmkdir /tmp/nginx/proxy_temptouch /var/run/nginx.pidtouch /var/log/nginx/error.logtouch /var/log/nginx/access.logtouch /var/lock/nginxchown nginx.nginx /etc/nginx/chown -R nginx.nginx /var/log/nginx/chown nginx.nginx /var/run/nginx.pidchown nginx.nginx /var/lock/nginxchown nginx.nginx /tmp/nginx -Rmkdir /usr/local/nginx/objs -p--mkdir /usr/src/pcre/Makefilechown nginx.nginx /usr/local/nginx -Rwget http://nginx.org/download/nginx-1.4.7.tar.gztar -xvf nginx-1.4.7.tar.gz -C /usr/src/cd /usr/src/mv nginx-1.4.7/ nginxcd nginx/./configure --prefix=/usr/local/nginx  --sbin-path=/sbin/nginx  --conf-path=/etc/nginx/nginx.conf  --with-cc=/usr/bin/gcc --error-log-path=/var/log/nginx/error.log  --pid-path=/var/run/nginx.pid  --lock-path=/var/lock/nginx  --builddir=/usr/local/nginx/objs --with-perl=/usr/bin/perl --http-log-path=/var/log/nginx/access.log --user=nginx  --group=nginx   --http-proxy-temp-path=/tmp/nginx/proxy_temp --with-pcre --with-pcre=/usr/src/pcre --with-openssl=/usr/src/openssl --with-zlib=/usr/src/zlib --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_mp4_module  --with-http_flv_modulemake && make installnginx ps -ef | grep nginx
#!/bin/bash#脚本对日志文件进行切割#脚本需要crontab 每天定时执行#Nginx 日志文件的存放路径logs_path="/../logs/"mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/echo "-----------------"mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").logkill -USER1 `cat /../nginx/nginx.pid`
crontab -e00 00 * * * /bin/bash /…/…/cut_nginx_log.sh
[root@mail init.d]# nl /etc/init.d/nginx      1	#!/bin/bash     2	# chkconfig: - 85 15     3	# description: The Apache HTTP Server is an efficient and extensible  \     4	#	       server implementing the current HTTP standards.     5	#     6	# Source function library.     7	. /etc/rc.d/init.d/functions     8	nginx=/usr/local/nginx/sbin/nginx     9	case $1 in    10		start)    11			num=`netstat -lanput | grep nginx | wc -l`    12			if [ $num -gt 0 ]    13			then    14				echo "nginx is running"	    15			else    16				$nginx && echo -ne "nginx is started\t\t\t[ \033[31;48mok\033[0m ]\n"    17			fi    18		;;    19		stop)    20			num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`    21			if [ $num2 -gt 0 ]    22			then    23				$nginx -s stop > /dev/null 2>&1	    24				num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`    25				if [ $num2 -gt 0 ]    26		                then    27					pkill -9 nginx    28				fi    29				num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`    30				if [ $num2 -eq 0 ]    31				then    32					echo -ne "nginx is stoped\t\t\t[ \033[31;48mok\033[0m ]\n"    33				else    34					echo -ne "nginx is stoped\t\t\t[ \033[31;48mfaild\033[0m ]\n"    35				fi    36			fi    37		;;    38		restart)    39			num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`    40	                if [ $num2 -gt 0 ]    41	                then    42	                        $nginx -s stop > /dev/null 2>&1    43	                        num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`    44	                        if [ $num2 -gt 0 ]    45	                        then    46	                                pkill -9 nginx    47	                        fi    48	                        num2=`ps -ef|grep "nginx:"|grep -v grep|wc -l`    49	                        if [ $num2 -eq 0 ]    50	                        then    51	                                echo -ne "nginx is stoped\t\t\t\t[ \033[31;48mok\033[0m ]\n"    52	                        else    53	                                echo -ne "nginx is stoped\t\t\t\t[ \033[31;48mfaild\033[0m ]\n"    54	                        fi    55	                fi    56			num=`netstat -lanput | grep nginx | wc -l`    57	                if [ $num -gt 0 ]    58	                then    59	                        echo "nginx is running"     60	                else    61	                        $nginx && echo -ne "nginx is started\t\t\t[ \033[31;48mok\033[0m ]\n"    62	                fi    63		;;    64		status)    65			num=`ps -ef|grep "nginx:"|grep -v grep|wc -l`    66	                if [ $num -eq 0 ]    67	                then    68				echo "nginx is stoped"     69			else    70				echo "nginx is runing"     71			fi    72		;;    73		*)    74			echo "Usage: nginx {start|stop|restart|status}"    75		;;    76	esac

  

  

  

  

转载于:https://www.cnblogs.com/similarface/p/5469789.html

你可能感兴趣的文章
Nodejs学习笔记(二):《node.js开发指南》代码中需要注意的几点
查看>>
Ztree异步加载自动展开节点
查看>>
反射操作公共成员变量
查看>>
Android热修复升级探索——代码修复冷启动方案
查看>>
学校宿舍的深夜之思考
查看>>
VB.NET 生成DBF文件
查看>>
编译安装nginx 1.9.15
查看>>
我的友情链接
查看>>
新的开始~~~
查看>>
字符串的扩展
查看>>
存储过程中调用webservice
查看>>
神奇语言 python 初识函数
查看>>
Windows安装Composer出现【Composer Security Warning】警告
查看>>
四 指针与数组 五 函数
查看>>
硬盘空间满了
查看>>
dutacm.club Water Problem(矩阵快速幂)
查看>>
深入JVM内核--GC算法和种类
查看>>
iOS的AssetsLibrary框架访问所有相片
查看>>
读书笔记三
查看>>
数论 - 最小乘法逆元
查看>>