一键架设
curl -k https://gitee.com/py4u/lite-server/raw/master/web.sh -o web.sh && bash web.sh
nohup python -m http.server 80 &//(这个后台不间断命令)
===========================Linux下命令行安装 Anaconda
wget https://repo.continuum.io/archive/Anaconda3-2018.12-Linux-x86_64.sh
bash Anaconda3-2018.12-Linux-x86_64.sh -p anaconda/ -u
cd anaconda
echo 'export PATH="/root/anaconda/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
conda --version
===========================================
web.py最后决定试一试dev的版本。
pip install web.py==0.40.dev0
最后发现 web.py 的dev版本 在python 3.x 上完美工作。
==========================================
安装http-server使用Deepin/Ubuntu,在终端输入:
sudo apt install npm //安装npm包管理器,如果是CentOS 使用yum不要用apt
sudo yum install npm //安装npm包管理器,如果是CentOS 使用yum不要用apt
sudo npm install http-server -g //参数-g表示全局安装,这样它就可以从终端运行,否则在终端输入http-server将提示找不到此命令。
测试:在建站目录下输入: http-server //启动http-server
nohup python -m http.server 80 &//(这个后台不间断命令)
在/etc/rc.local文件中添加你要运行的命令.(开机运行脚本)
/usr/bin/python3 /root/tweb/test.py &
至此布署完成,以下是踩的坑
# test.py代码
#!/usr/bin/env python
#--coding:utf-8--
from http.server import baseHTTPRequestHandler, HTTPServer
from os import path
from urllib.parse import urlparse
curdir = path.dirname(path.realpath(__file__))
sep = '/'
# MIME-TYPE
mimedic = [
('.html', 'text/html'),
('.htm', 'text/html'),
('.js', 'application/javascript'),
('.css', 'text/css'),
('.json', 'application/json'),
('.png', 'image/png'),
('.jpg', 'image/jpeg'),
('.gif', 'image/gif'),
('.txt', 'text/plain'),
('.avi', 'video/x-msvideo'),
]
class testHTTPServer_RequestHandler(baseHTTPRequestHandler):
# GET
def do_GET(self):
sendReply = False
querypath = urlparse(self.path)
filepath, query = querypath.path, querypath.query
if filepath.endswith('/'):
filepath += 'index.html'
filename, fileext = path.splitext(filepath)
for e in mimedic:
if e[0] == fileext:
mimetype = e[1]
sendReply = True
if sendReply == True:
try:
with open(path.realpath(curdir + sep + filepath),'rb') as f:
content = f.read()
self.send_response(200)
self.send_header('Content-type',mimetype)
self.end_headers()
self.wfile.write(content)
except IOError:
self.send_error(404,'File Not Found: %s' % self.path)
def run():
port = 80
print('starting server, port', port)
# Server settings
server_address = ('', port)
httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
print('running server...')
httpd.serve_forever()
if __name__ == '__main__':
run()
=======================================
nohup http-server & //(这个后台不间断命令)
什么?没有80服务? 一键架设
curl -k https://gitee.com/py4u/lite-server/raw/master/web.sh -o web.sh && bash web.sh
============================================
mkdir /usr/local/python3/
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1rc2.tgz
mv Python-3.7.1rc2.tgz /usr/local/python3
cd /usr/local/python3
tar -zxf Python-3.7.1rc2.tgz
cd ./Python-3.7.1rc2
./configure --with-ssl
make && make install
yum install -y gcc
yum install -y zlib*
yum install -y libffi-devel
echo "/usr/python/lib" >> /etc/ld.so.conf
ln -s /usr/python/bin/python3 /usr/bin/python3
ln -s /usr/python/bin/pip3 /usr/bin/pip3
python3 --version
python2 --version
pip3 list
======= 安装成功显示=========
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
=============
python2.7 安装:
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar jxvf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure
make && make install
直接下载web.py安装文件,用Xshell工具上传(直接用命令易出错)
http://webpy.org/static/web.py-0.37.tar.gz
进行下载,下载好之后进行解压 tar -zxvf web.py-0.37.tar.gz
cd web.py-0.37 继续安装 python setup.py install 返回上级目录 cd ..
安装setuptools(2022版)(注意一下目录)cd ..
wget --no-check-certificate https://files.pythonhosted.org/packages/14/74/54890935244ce053abcc4fa01ef4982a84743a8d128d4cf5eae56e2d156c/setuptools-60.9.3.tar.gz
tar -zxvf setuptools-60.9.3.tar.gz
cd setuptools-60.9.3
python3 setup.py build
python3 setup.py install
安装pip命令如下:(注意一下目录) cd ..
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.2.tar.gz
cd pip-8.0.2
python3 setup.py build
python3 setup.py install
安装webpy(实时最新)
1.使用 git clone https://github.com/SmartDengC/webpy.git 克隆webpy项目
2.进入webpy文件夹, 运行 python3 setup.py install



