Nginx日志-访问量统计

nginx访问量统计

1.根据访问IP统计UV

awk '{print $1}'  access.log|sort | uniq -c |wc -l

2.统计访问URL统计PV

awk '{print $7}' access.log|wc -l

3.查询访问最频繁的URL

awk '{print $7}' access.log|sort | uniq -c |sort -n -k 1 -r|more

4.查询访问最频繁的IP

awk '{print $1}' access.log|sort | uniq -c |sort -n -k 1 -r|more

5.根据时间段统计查看日志

 cat  access.log| sed -n '/14\/Mar\/2015:21/,/14\/Mar\/2015:22/p'|more

PHP7.4.9环境安装

1. 下载安装编译工具

yum groupinstall 'Development Tools'

2.安装依赖包

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel

3.下载并解压php7.4.9

wget http://php.net/distributions/php-7.4.9.tar.gz
tar -zxvf php-7.4.0.tar.gz 
cd php-7.4.0

4.编译安装(./configure –help 查看编译参数)

编译前,新增用户组,用户,用于编译使用

groupadd www
useradd -g www www

开始编译(根据自己需要增减)

./configure --prefix=/usr/local/php-7.4.9 --with-config-file-path=/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --enable-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm

 

注意:发生错误时

  • 当报错checking for libzip… configure: error: system libzip must be upgraded to version>= 0.11
#先删除旧版本
yum remove -y libzip

#下载编译安装
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
  • error:Package requirements (sqlite3 > 3.7.4) were not met
yum install libsqlite3x-devel -y
  • error: Package requirements (oniguruma) were not met
yum install oniguruma-devel -y

编译没问题了,执行安装

make && make install

5.配置环境

执行完安装命令后php7.4就已经安装在到了/usr/local/php目录下了

/usr/local/php-7.4.9/bin/php -v

添加环境变量

vim /etc/profile
# 添加到最后
PATH=$PATH:/usr/local/php/bin
export PATH
# 更新环境变量
source /etc/profile
# 查看版本
php -v

6.配置php-fpm

cp php.ini-production /etc/php.ini
cp /usr/local/php-7.4.9/etc/php-fpm.conf.default /usr/local/php-7.4.9/etc/php-fpm.conf
cp /usr/local/php-7.4.9/etc/php-fpm.d/www.conf.default /usr/local/php-7.4.9/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

启动php-fpm

/etc/init.d/php-fpm start
或者
service php-fpm start

Python环境安装

更新系统环境

yum update -y && yum install gcc openssl-devel lrzsz libffi-devel python-devel openssl-devel libxslt-devel libxml2-devel telnet sar mlocate  gcc+ gcc-c++ bzip2 git flex bison clang libpcap-devel libXext libXrender fontconfig libfontconfig.so.1 libXtst make -y

安装python

cd /root/soft && wget http://git_yunsee.vuln.cn/haoqiangjian/yunxi_data_manage/raw/master/soft/Python-3.6.5.tar.xz && tar -xvJf Python-3.6.5.tar.xz && cd Python-3.6.5 && ./configure --prefix=/usr/local/python3.6 --with-ssl && make && make install && ln -sf /usr/local/python3.6/bin/pip3 /usr/bin/pip3 && ln -sf /usr/local/python3.6/bin/python3.6 /usr/bin/python3

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn celery==4.3.0 redis requests bs4
ln -sf /usr/local/python3.6/bin/celery /usr/bin/celery
ln -sf /usr/local/python3.6/bin/gunicorn /usr/bin/gunicor

安装常用工具

yum install epel-release -y && yum install htop supervisor -y

 

给Git设置代理

设置全局代理

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

取消全局代理

git config --global --unset http.proxy
git config --global --unset https.proxy

只对github.com代理

git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

取消github.com代理

git config --global --unset http.https://github.com.proxy