#本人新手寫的不好之處,一定要指點我。我會不定期更新這個內容。
1、輸入IP地址查找/etc/hosts文件中指定的域名
#!/bin/sh #author vperson #qq 737304790 #Enter the specified IP to find the corresponding domain name in the hosts file flag=0 if [ $# -ne 1 ] then echo "Input error" echo "Usage: $0 127.0.0.1" exit 1 fi exec < /etc/hosts while read line do if [ "$1" = "`echo $line|awk '{print $1}'`" ] then flag=1 printf "Successfully find the domain name!\n" echo -e "\033[31m $1==>> `echo $line|awk '{print $2}'` \033[0m" break fi done [ ${flag} -eq 0 ] && echo "No specified IP"
2、Centos 7一鍵安裝ngixn
#!/bin/sh #author vperson #qq 737304790 #variable TOOLS=/root/toolsdown NGINXDIR=/usr/local/nginx-1.4.7 #View the current user [ $UID -eq 0 ] || { echo "Not enough authority" exit 1 } #Create a working directory mkdir -p ${TOOLS} && cd ${TOOLS} if [ $? -eq 0 ] then echo "Directory created successfully" else echo "Directory creation failed" exit 1 fi #Solve dependency package yum install gcc gcc-c++ zlib-devel pcre-devel openssl-devel -y &> /dev/null || { echo "Yum installation error" exit 1 } #Download the nginx source package wget http://nginx.org/download/nginx-1.4.7.tar.gz if [ $? -ne 0 ] then echo "Download nginx source package failed" exit 1 else echo "Download nginx source package successfully" fi #Compile and install nginx tar xf nginx-1.4.7.tar.gz if [ $? -ne 0 ] then echo "Unpack the nginx source package failed" eixt 1 else echo "Unpack the nginx source package successfully" cd nginx-1.4.7 || { echo "Failed to enter the nginx directory" exit 1 } fi #Create a nginx user useradd -r nginx #if [ $? -ne 0 ] # then # `rpm -qa | grep nginx` && yum remove nginx -y #fi #Compile and install nginx printf " parameter\n --prefix=/usr/local/nginx-1.4.7\n --user=nginx\n --group=nginx\n --with-pcre\n --with-http_ssl_module\n --with-http_stub_status_module\n " ./configure --prefix=/usr/local/nginx-1.4.7 \ --user=nginx \ --group=nginx \ --with-pcre \ --with-http_ssl_module \ --with-http_stub_status_module if [ $? -ne 0 ] then echo "configure failed" exit 1 fi make && make install if [ $? -ne 0 ] then echo "make && make install failed" exit 1 else echo "make && make install successfully" fi $NGINXDIR/sbin/nginx && echo "Nginx started successfully" if [ $? -ne 0 ] then echo "Nginx started failed" fi