手撕包菜(DHT磁力)一键安装、创建Nginx反代、设置SSL连接

适用于有swap、系统为centos 7的VPS。

一、安装手撕包菜
1、卸载apache

yum -y remove httpd

并安装必要组件

yum update -y
yum install screen wget unzip gcc gcc-c++ python-devel -y

关闭防火墙

systemctl stop firewalld.service ; systemctl disable firewalld.service

2、安装

wget https://zhujiwiki.com/wp-content/uploads/2016/03/ssbc1.1.sh
sh ssbc1.1.sh

在是否可以用浏览器浏览网页处,选择 Y,然后设置用户名、密码

3、设置定时重启

wget https://zhujiwiki.com/wp-content/uploads/2016/03/ssbc-reboot.sh
chmod +x ssbc-reboot.sh
crontab -e

按i进入编辑模式

0,30 * * * * sh /root/ssbc-reboot.sh

按Esc键退出编辑模式,然后按着shift并同时连按2次z,即回到shell界面。

0,30 sh /root/ssbc-reboot.sh
意思是每小时的0分和30分自动执行ssbc-reboot.sh这个文件

也可以设置的时间长点,如每天晚上1点重启:

0 1 * * * sh /root/ssbc-reboot.sh

或者每2小时重启1次:

0 */2 * * * sh /root/ssbc-reboot.sh

这时候,磁力站已经搭建好了,使用你的服务器IP就可以访问,也可以绑定域名。

二、安装Nginx、PHP,设置SSL私密连接
下面出现的:8080端口,也可以更改为其他端口。

1、kill掉 手撕包菜的进程
检测python 80端口进程ID:

ps aux | grep python

ssbc-nginx.jpg

kill -9 2344 2439

2、安装Nginx、PHP
a、使用LNMP一键安装包,安装Nginx、PHP,其他均不装。
b、安装Let’s Encrypt client

./addons.sh

选择7,安装即可。(Let’s Encrypt client是免费的SSL证书)

3、编辑防火墙,允许:8080端口通信

vi /etc/sysconfig/iptables

添加

-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT

重启防火墙

systemctl reload iptables.service

4、创建网站,并设置反代
a、创建网站

cd /root/lnmp
./vhost.sh

b、设置反代

cd /usr/local/nginx/conf/vhost

编辑之前创建的网站配置:

vi freecili.com.conf

添加如下代码:

location / {
    proxy_pass http://你的服务器IP:8080;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    client_max_body_size 1024M; # Set higher depending on your needs
}

你的服务器IP 设置为你的IP地址

重启Nginx服务

service nginx restart

5、重建手撕包菜进程:

cd /root/ssbc-master
nohup python manage.py runserver 0.0.0.0:8080 >/dev/zero &

6、编辑ssbc-reboot.sh
a、更改ssbc-reboot.sh里的端口为8080

vi ssbc-reboot.sh

ssbc-boot.jpg

b、添加重启Nginx命令
在第三行下添加:

systemctl restart nginx.service

演示http://cili.sib8.net/

7、关闭、禁止firewall、iptables

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl stop iptables.service
systemctl disable iptables.service

三、部分问题解决
1、搬家可直接搬数据库:/var/lib/mysql/ssbc/
然后执行命令:

chmod +x /etc/rc.d/rc.local
echo "systemctl start  mariadb.service " >> /etc/rc.d/rc.local
echo "cd /root/ssbc-master " >> /etc/rc.d/rc.local
echo "indexer -c sphinx.conf --all " >> /etc/rc.d/rc.local
echo "searchd --config ./sphinx.conf " >> /etc/rc.d/rc.local
echo "nohup python manage.py runserver 0.0.0.0:80 >/dev/zero 2>&1& " >> /etc/rc.d/rc.local
echo "cd workers " >> /etc/rc.d/rc.local
echo "nohup python simdht_worker.py >/dev/zero 2>&1& " >> /etc/rc.d/rc.local
echo "nohup python index_worker.py >/dev/zero 2>&1& " >> /etc/rc.d/rc.local

然后再重启就正常了

2、搜索中文报错
如果是centos7系统,修改/usr/lib64/python2.7/site.py
vi /usr/lib64/python2.7/site.py
在import sys下添加2行:
reload(sys)
sys.setdefaultencoding(‘utf8’)

3、如何确认web服务器、采集、入库正在运行?
ps -ef|grep python
结果里面有
python manage.py runserver 0.0.0.0:80
python simdht_worker.py
python index_worker.py
即表示正在运行。

via:hostloc1hostloc2,部分有修改。

    所有主机信息仅是为及时分享并收录,不做推荐!
    专门搜集、分享国内高速、稳定的香港、日本、韩国、新加坡、美西CN2等优质线路的主机:FastVM