shell脚本 查看 mysql nginx php 是否运行

#!/bin/bash
#
#ps -ef | grep -i mysql | grep -v root | awk '{print $2}'
PATH_NAME='/shTest/position/'
FILE_NAME='position.cpy'

#获取配置文件
get_all_group(){
        if [ -e $PATH_NAME$FILE_NAME ]
        then
                GROUP_LIST=`sed -n '/\[GROUP\]/,/\[.*\]/p' $PATH_NAME$FILE_NAME | egrep -v '(^$|\[.*\])'`
                echo "$GROUP_LIST"
        else
                echo "文件不存在!"
        fi
}

#获取配置文件参数里的 pid
get_group_pid()
{
        group_pid=`ps -A | grep -i $1 | awk '{print $1}' | head -1`
        #echo $group_pid
        if [ $group_pid ]
        then
                echo $group_pid
        else
                echo Null
        fi;
}

#获取列表组 参数信息
get_group_list()
{
        echo "NAME"" ----------------- ""PID"" ----------------- ""GROUP"
        for list in `get_all_group`
        do
                #echo "sed -n '/\[$list\]/,/\[.*\]/p' $PATH_NAME$FILE_NAME | egrep -v '(^$|\[.*\])'"
                group_name=`sed -n "/\[$list\]/,/\[.*\]/p" $PATH_NAME$FILE_NAME | egrep -v '(^$|\[.*\])'`
                echo $group_name" ----------------- "`get_group_pid $group_name`" ----------------- "$list
        done
}

get_group_list


position.cpy 文件信息
[GROUP]
WEB
DB
PROGRAMING

[WEB]
NGINX

[DB]
MYSQL

[PROGRAMING]
PHP

websocket nginx代理

upstream websocket {
        server 127.0.0.1:6777;
}


location / {
                proxy_pass http://websocket;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection “Upgrade”;
}

// wss

ssl on;
    ssl_certificate /xxx/xxx/nginx/hxr.crt;
    ssl_certificate_key /xxx/xxx/nginx/hxr.key;

    ssl_session_timeout 5m;
    ssl_session_cache shared:SSL:50m;
    ssl_protocols TLSV1.1 TLSV1.2 SSLv2 SSLv3;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers on;

    server {
        listen 443;
        server_name xxx.xxx;
        location / {
                proxy_pass http://websocket;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection “Upgrade”;
        }
    }

nginx geoip 模块 使用

$ wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
$ tar -zxvf GeoIP.tar.gz
$ cd GeoIP-1.4.8
$ ./configure
$ make
$ make install
$ ./configure --with-http_geoip_module 
    
$ make && make install

geoip_country /web/test/nginx/packbag/GeoIP.dat;

#location / {
        #       default_type ‘text/plain’;
        #       add_header Content-type ‘text/html;charset=utf-8’;
                #return 200 ‘$geoip_country_code’;
        #       content_by_lua_file conf/test1.lua;
                #return 200 ‘{“http_user_agent”:”$http_user_agent”,”remote_user”:”$remote_user”,”tcp”:”$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space”,”content_type”:”$content_type”,”host”:”$host”,”remote_addr”:”$remote_addr”,”args”:”$args”}’;
        #}

shadowsocks

pip install shadowsocks
sudo vim /etc/shadowsocks.json
//这里的json文件是自己创建的,不是系统自带

配置文件的内容大致如下:

{
    "server":"服务器的ip",
    "server_port":19175,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"密码",
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open":false
}

sssever -c shadowsocks.json

lanp shell脚本下载安装

    #!bin/bash
    #
    
    #php 安装
    echo "php安装路径:"
    read php_name
    echo "php安装路径为:$php_name"
    echo `wget http://cn2.php.net/get/php-7.3.2.tar.bz2/from/this/mirror`
    echo `mv mirror php.tar.bz2`
    echo `tar -xvf php.tar.bz2`
    rm php.tar.bz2
    cd php-7.3.2
    pwd
    echo `./configure --prefix=/soft/php --with-openssl --with-config-file-path=/soft/php --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --with-libxml-dir=/usr --with-xmlrpc --enable-fpm --enable-xml --enable-sockets --with-gd --with-iconv --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl
`
    echo `make && make install`
    echo `cp php.ini-production $php_name/php.ini`
    cd $php_name/etc
    mv php-fpm.conf.default php-fpm.conf
    cd $php_name/etc/php-fpm.d
    mv www.conf.default www.conf
    
    
    #mysql 下载
    echo "mysql安装路径:"
    read mysql_name
    echo "mysql安装路径:$mysql_name"
    echo `wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz`
    mv mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz $mysql_name/mysql.tar.xz
    cd $mysql_name
    echo `tar -xvf mysql.tar.xz`
    rm mysql.tar.xz
    mv mysql-8.0.15-linux-glibc2.12-x86_64/ mysql/
    echo `chown -R mysql:mysql mysql/`
    cd mysql/
    mkdir data
    
    cat>mysql.sock<<EOF
    EOF
    
    echo `chown -R mysql:mysql mysql.sock`
    
    cat>my.cnf<<EOF
    [mysqld]
    port=3406
    basedir=$mysql_name/mysql
    datadir=$mysql_name/mysql/data
    socket=$mysql_name/mysql/mysql.sock
    EOF
    groupadd mysql
	useradd -r -g mysql mysql
	chown -R mysql:mysql $mysql_name/
    
    cd bin
    echo `./mysqld --defaults-file=$mysql_name/mysql/my.cnf --initialize --user=mysql`
    echo `./mysqld_safe --user=mysql &`
    #nginx 安装
    echo "nginx安装路径:"
    read nginx_name
    echo "nginx安装路径为:$nginx_name"
    
    echo `wget http://nginx.org/download/nginx-1.14.2.tar.gz`
    echo `tar -xvf nginx-1.14.2.tar.gz`
    rm nginx-1.14.2.tar.gz
    cd nginx-1.14.2
    echo `./configure --prefix=$nginx_name --with-http_ssl_module`
    echo `make && make install`
    sed -i "s/\/scripts\$fastcgi_script_name/\$document_root\$fastcgi_script_name/g" $nginx_name/conf/nginx.conf