perloader

开启MySQL远程访问权限

1.ping 远程地址 判断远端服务网络正常 2.telnet 远程地址 端口号,拒绝了访问3306端口 telnet 192.168.99.100 3306 3.登录远端服务器,查看远端服务器3306端口是否开启,如果是127.0.0.1:3306,修改MySQL配置文件,将bind_address = 127.0.0.1注释掉或修改成0.0.0.0 netstat -an|grep 3306 tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 4.编辑后重启mysql ,再次查看3306端口 service mysqld restart sudo netstat -an|grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 5.授权访问,用root身份登录到mysql,使用grant命令分配权限,如果操作所有库就把 database_name.* 改成 *.* ,user_name是用户名,%是所有ip地址可访问,如果限制固定ip访问就改成ip,user_password是密码, mysql -uroot -p mysql> grant all on database_name.* to user_name@’%’ identified by ‘user_password’; mysql> […]

.

Read more

减轻WordPress负载

1.禁用 WP Cron WordPress 有个进程专门用来在指定的时间周期或者将来的某个时间点运行特定的任务,比如定时发布某篇日志。这个功能 WordPress 是通过 WP-Cron 实现的,它会在每次你的博客有人访问或者在后台工作的时候,都会去检查当前是否有任务要执行。这样可能会引起一些问题: 增加服务器加载时间,特别是网站访问用户特别多的时候。 而网站的访问用户很少或者加载了静态缓存插件,指定的任务可能又不运行。 所以最好不要让 WordPress 在后台执行 WP-Cron,而是使用服务器的真正的定时 Cron 功能来执行。 可以通过在 wp-config.php 添加下面的代码禁用 WP-Cron: /* Disable background wp-cron */ define(‘DISABLE_WP_CRON’, true); 可以使用服务器自带的cron,设置比如说2小时访问一次,wp-cron.php: wget http://YourDomain.com/wp-cron.php   2.合理配置 PHP-FPM 打开 /etc/php–fpm.d/www.conf ,配置39 和 41行用户名和组为nginx 。其中必须关闭156行,删除如下语句 slowlog = /var/log/php–fpm/www–slow.log 这是个 BUG ,记录慢日志的话 PHP 必然会内存溢出导致所有 PHP 全部报错。将这行前面打个冒号注释掉就可以了。 /usr/local/php/etc/php-fpm.conf       via:https://www.mywpku.com/wordpress-ultimate-speed-up-course-first.html

.

Read more

UnixBench跑分排行

测试方法: wget –no-check-certificate https://github.com/teddysun/across/raw/master/unixbench.sh chmod +x unixbench.sh ./unixbench.sh m247.ro,2核,1G内存,5 IP,KVM VPS,罗马尼亚,月付12.5€,2630.5 E5-2620v3 – 3.2Ghz next next next next

.

Read more

nginx 只允许特定IP访问

1.单独网站屏闭IP的方法: 在server”{}”,在这个大括号内加入deny IP地址是限制某IP地址访问;allow IP地址是只允许某IP地址访问; 如: allow 203.137.116.106; allow 118.0.0.0/8; deny all; 2.全局屏蔽 首先建立下面的配置文件放在nginx的conf目录下面,命名为blocksip.conf。比如我们要拒绝ip: deny 118.114.245.37; 保存一下。 在nginx的配置文件nginx.conf中加入:include blocksip.conf; 重启一下nginx的服务就可以生效了。

.

Read more

Nginx 反向代理以及正则替换内容

如果是为了隐藏源站IP而使用Nginx 反向代理,可以将源站域名替换为一个不存在的子域名,然后在代理机上vi /etc/hosts,将这个不存在的子域名指向源站IP。 安装nginx cd /root apt-get update apt-get install -y git gcc g++ make automake sudo apt-get install libpcre3 libpcre3-dev sudo apt-get install openssl libssl-dev apt-get install zlib1g-dev 或者 yum -y install pcre-devel openssl openssl-devel git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module wget http://nginx.org/download/nginx-1.2.8.tar.gz wget http://nginx.org/download/nginx-1.19.0.tar.gz tar zxvf nginx-1.2.8.tar.gz cd nginx-1.2.8 ./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_gzip_static_module […]

.

Read more

win7安装MongoDB

下载mongodb-win32-x86_64-2.4.5.zip这个版本 解压至C盘,并建立C:\mongodb\DB文件夹和C:\mongodb\log\log.txt文件 管理员模式运行CMD cd mongodb\bin\ mongod.exe –logpath=C:\mongodb\log\log.txt –dbpath=C:\mongodb\data\db mongod.exe –install –logpath=C:\mongodb\log\log.txt –dbpath=C:\mongodb\data\db net start mongodb 启动mongodb服务 sc delete MongoDB 删除mongodb服务 启动后,再到命令行输入 mongo 如果成功的进入mongo的shell环境,那么就说明MongoDB已经安装成功了  

.

Read more

列表解析式

urls = [“http://www.hostloc.com/forum-45-{}.html”.format(str(i)) for i in range(1,15,1)] print(urls) 运行结果 [‘http://www.hostloc.com/forum-45-1.html’, ‘http://www.hostloc.com/forum-45-2.html’, ‘http://www.hostloc.com/forum-45-3.html’, ‘http://www.hostloc.com/forum-45-4.html’, ‘http://www.hostloc.com/forum-45-5.html’, ‘http://www.hostloc.com/forum-45-6.html’, ‘http://www.hostloc.com/forum-45-7.html’, ‘http://www.hostloc.com/forum-45-8.html’, ‘http://www.hostloc.com/forum-45-9.html’, ‘http://www.hostloc.com/forum-45-10.html’, ‘http://www.hostloc.com/forum-45-11.html’, ‘http://www.hostloc.com/forum-45-12.html’, ‘http://www.hostloc.com/forum-45-13.html’, ‘http://www.hostloc.com/forum-45-14.html’]

.

Read more

自写的第一个爬取图片实例

老套的爬图片实例,陆续写了几天,不容易,终于出来了。 难点有:分别为图片创建文件夹,爬取时不惧怕防盗链。 没有定义函数 比较难看,哈哈 from bs4 import BeautifulSoup import requests import urllib.request import os import re website = “http://www.sucaibar.com/image/meinv/” web_data = requests.get(website) soup = BeautifulSoup(web_data.text,’lxml’) urls= soup.select(‘#pic-list > li > a’) url_list = [] for url in urls: url_list.append(url.get(‘href’)) print(url_list) for url in url_list: web_data = requests.get(url) soup = BeautifulSoup(web_data.text,’lxml’) links= soup.select(‘body > div.content > […]

.

Read more

Windows上Python3.5安装lxml

pip install wheel http://www.lfd.uci.edu/~gohlke/pythonlibs/ 找到 lxml-3.6.4-cp35-cp35m-win32.whl lxml-3.6.4-cp35-cp35m-win_amd64.whl 放到Python 目录下 pip install lxml-3.6.4-cp35-cp35m-win_amd64.whl

.

Read more

火车头发布wordpress,定时发布过期,mysql批量修改

用火车头采集,然后发布至wordpress,由于时间成千上万条,定时发布会有很多失败也就是过期的,可以使用mysql命令行批量修改 。 先找出最近还没发布的post 的ID UPDATE wp_posts SET post_status = ‘publish’ WHERE ID < 23790 AND post_status = ‘future’;  

.

Read more
xyz