# 安装 pure-ftpd
apt-get install pure-ftpd
安装包cd /etc/pure-ftpd/auth && ln -s /etc/pure-ftpd/conf/PureDB 60puredb
cd /etc/pure-ftpd/conf
进入配置目录echo 33 > MinUID
www-dataecho 30000 30100 > PassivePortRange
远程连接数据库端口,需要配置防火墙echo yes > ChrootEveryone
www-dataecho yes > DisplayDotFiles
显示隐藏文件echo 90 > MaxDiskUsage
文件所在磁盘的最大使用率
/etc/init.d/pure-ftpd start
启动 pure-ftpdstop
暂停restart
重新启动
netstat -tnlp
查看端口连接是否正常pure-pw useradd account -u www-data -d /data/wwwroot/account
添加账号,并指定目录pure-pw mkdb
更新数据库pure-pw list
列出账号列表pure-pw show ftp_user2
查看账号信息pure-pw userdel ftp_user2
删除账号
# 安装 apache2 与对应 php 版本包 php7.0
apt-get install apache2
安装包apt-get install libapache2-mod-php7.0
安装包sudo a2enmode rewrite
或者sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
开启Apache的Rewrite
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All // None 改为 All
Require all granted
</Directory>
apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages \
php7.0-cli php7.0-dev \
php7.0-sqlite3 php7.0-gd \
php7.0-curl \
php7.0-imap php7.0-mysql php7.0-mbstring \
php7.0-xml php7.0-zip php7.0-bcmath php7.0-soap \
php7.0-intl php7.0-readline php-pear php7.0-fpm
// 配置 php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini
sed -i "s/memory_limit = .*/memory_limit = 128M/" /etc/php/7.0/fpm/php.ini
sed -i "s/upload_max_filesize = .*/upload_max_filesize = 20M/" /etc/php/7.0/fpm/php.ini
sed -i "s/post_max_size = .*/post_max_size = 20M/" /etc/php/7.0/fpm/php.ini
// 根据服务器性能配置 fpm
sed -i "s/pm.max_children =.*/pm.max_children = 80/" /etc/php/7.0/fpm/pool.d/www.conf
sed -i "s/pm.start_servers =.*/pm.start_servers = 20/" /etc/php/7.0/fpm/pool.d/www.conf
sed -i "s/pm.min_spare_servers =.*/pm.min_spare_servers = 10/" /etc/php/7.0/fpm/pool.d/www.conf
sed -i "s/pm.max_spare_servers =.*/pm.max_spare_servers = 40/" /etc/php/7.0/fpm/pool.d/www.conf
sed -i "s/pm.max_requests =.*/pm.max_requests = 1024/" /etc/php/7.0/fpm/pool.d/www.conf
/etc/init.d/php7.0-fpm restart
重启 php
# Ubuntu 16.04 安装 Docker
apt-get remove docker docker-engine docker-ce docker.io
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
cd /etc/docker // 进入目录创建 daemon.json
// 修改镜像源
{
"registry-mirrors": ["https://cr.console.aliyun.com"]
}
docker 常用命令
docker pull node:10-slim
拉取镜像docker images
查看镜像docker build -t docker_demo .
根据 Dockerfile 构建镜像, .dockerignore 类似 git 忽略文件docker run -d docker_demo
根据镜像创建一个容器docker stop $(docker ps -a -q)
暂停所有容器docker rm $(docker ps -a -q)
删除所有容器docker exec -it 9df70f9a0714 /bin/sh
开启一个交互模式的终端docker save imageName > | gzip > imageName.tgz
打包并压缩镜像docker load < imageName.tgz
解压成镜像
apt-get install docker-compose
- 配置文件
version: '2' services: node001: restart: always image: docker_demo node002: restart: always image: docker_demo
docker-compose up -d nginx 构建建启动nignx容器
docker-compose exec nginx bash 登录到nginx容器中
docker-compose down 删除所有nginx容器,镜像
docker-compose ps 显示所有容器
docker-compose restart nginx 重新启动nginx容器
docker-compose run --no-deps --rm php-fpm php -v 在php-fpm中不启动关联容器,并容器执行php -v 执行完成后删除容器
docker-compose build nginx 构建镜像 。
docker-compose build --no-cache nginx 不带缓存的构建。
docker-compose logs nginx 查看nginx的日志
docker-compose logs -f nginx 查看nginx的实时日志
docker-compose config -q 验证(docker-compose.yml)文件配置,当配置正确时,不输出任何内容,当文件配置错误,输出错误信息。
docker-compose events --json nginx 以json的形式输出nginx的docker日志
docker-compose pause nginx 暂停nignx容器
docker-compose unpause nginx 恢复ningx容器
docker-compose rm nginx 删除容器(删除前必须关闭容器)
docker-compose stop nginx 停止nignx容器
docker-compose start nginx 启动nignx容器
# Docker 构建 node + Chrome
FROM node:10-slim
MAINTAINER test
# 安装puppeter依赖
#COPY ./sources.list /etc/apt/sources.list
RUN apt update && apt install -y libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
RUN npm config set registry https://registry.npm.taobao.org
RUN npm config set puppeteer_download_host=https://npm.taobao.org/mirrors
#ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD yes
#RUN npm install puppeteer
# 配置负载均衡
upstream browserless-nodes {
least_conn;
server 127.0.0.1:3000 weight=100;
server 192.168.1.25:3000 weight=50;
}
server {
listen 8088 default_server;
server_name _;
location / {
proxy_pass http://browserless-nodes;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
// proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Docker 阿里云容器镜像
apt-get install pass || apt install gnupg2 pass
apt-get install rng-tools
wget https://github.com/docker/docker-credential-helpers/releases/download/v0.6.0/docker-credential-pass-v0.6.0-amd64.tar.gz && tar -xf docker-credential-pass-v0.6.0-amd64.tar.gz && chmod +x docker-credential-pass && sudo mv docker-credential-pass /usr/local/bin/
gpg2 --gen-key || gpg2 --full-generate-key
pass init "<Your Name>" // uid name 不带邮箱
sed -i '0,/{/s/{/{\n\t"credsStore": "pass",/' ~/.docker/config.json
# Docker 本地镜像
docker run -d -p 5000:5000 --restart always --name registry registry:2 // 先获取并运行 docker 官方的 repository 镜像 --restart选项是在docker-ce启动时会自动启动,always是级别,stop掉了会不自动重启。
修改daemon.json文件(如果没有就创建)
vim /etc/docker/daemon.json
{
"insecure-registries": [
"repository:5000"
]
}
repository 是主机名,可以使用ip,5000是运行registry时指定的端口,可以指定多个本地仓库,用,间隔
/etc/init.d/docker restart // 重启 docker
docker tag centos repository:5000/centos // 给本地镜像打标签
docker push repository:5000/centos // 将本地镜像上传到本地镜像仓库
docker pull repository:5000/centos // 获取镜像
# Python + Selenium
- 安装 python
apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
add-apt-repository ppa:fkrull/deadsnakes
cd /etc/apt/sources.list.d && sudo mv jonathonf-python-3_7-trusty.list ~ // 如果更新提示错误,进入 /etc/apt/sources.list.d 把跟 python
相关的移除源
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys key // 如果是 key 错误 NO_PUBKEY
apt-get update
apt-get install python3.6
python --version
apt-get install python3-pip #装pip3
- 修改 python 默认版本
update-alternatives --install /usr/bin/python python /usr/bin/python2 1
update-alternatives --install /usr/bin/python python /usr/bin/python3 2
update-alternatives --config python // 切换 Python 版本
- Linux 下安装插件慢,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件)
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
- 安装chrome
apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt-get install -f // 第三步
dpkg -i google-chrome-stable_current_amd64.deb // 第四步
- 安装chromedriver
wget -N https://npm.taobao.org/mirrors/chromedriver/80.0.3987.106/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
chmod +x chromedriver
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedrive
https://docs.browserless.io/docs/python.html // browserless
crontab 定时执行 python 的时候,查看下系统环境变量 echo $PATH,是否包含所需要的环境变量,然后再调试
/root/py-rank/python.py > /root/1.log 2 > &1 打印错误日志
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin && /root/python.py
# 修改 jenkins 为 root 用户
vim /etc/default/jenkins
JENKINS_USER="root"
JENKINS_GROUP="root"
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
# 重启 Jenkins(若是其他方式安装的jenkins则重启方式略不同)
service jenkins restart
# 查看Jenkins进程所属用户
ps -ef | grep jenkins
# 若显示为root用户,则表示修改完成
Iview →