阿里云服务器,最低配ECS服务器,学生认证白菜价,很适合做项目练手。
第一次做项目,加上是Linux小白,所以这里记录一下,配置服务器环境的过程。
这个工具蛮良心的,35元升级专业版,但是免费版也完全够用。
Windows 应该是XShell+Xftp
名称、主机
分别对应阿里云服务器控制台里的名称和公网IP
用户名、密码
是在购买服务器时设置的,一般用户名是root
[root@******* ~]# cd /etc/yum.repos.d/
[root@******* yum.repos.d]# mkdir bak
[root@******* yum.repos.d]# mv * bak
[root@******* yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
[root@******* yum.repos.d]# wget http://mirrors.aliyun.com/repo/epel-7.repo
[root@******* ~]# yum -y install zlib-devel bzip2-devel openssl-devel openssl-static ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel lzma gcc
[root@******* ~]# yum -y groupinstall "Development tools"
[root@******* ~]# cd /usr/local/src/
[root@******* src]# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
[root@******* src]# tar xvf Python-3.7.0.tar.xz
[root@******* src]# mv Python-3.7.0 /usr/local/python-3.7
[root@******* src]# cd /usr/local/python-3.7/
LD_RUN_PATH=/usr/local/lib ./configure LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" --prefix=/usr/local/sbin/python-3.7
LD_RUN_PATH=/usr/local/lib make
make && make install
然后出现
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
Python3.7安装成功
[root@******* ~]# which python
//找到系统自带老版本python绝对路径
/usr/bin/python
[root@******* ~]# ll /usr/bin/ |grep python
//查看当前连接
-rwxr-xr-x. 1 root root 11312 Nov 14 00:00 abrt-action-analyze-python
lrwxrwxrwx. 1 root root 7 Mar 14 18:19 python -> python2
lrwxrwxrwx. 1 root root 9 Mar 14 18:19 python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 Oct 31 07:46 python2.7
//建立新的软连接
[root@******* ~]# rm -rf /usr/bin/python
[root@******* ~]# ln -sv /usr/local/sbin/python-3.7/bin/python3 /usr/bin/python
‘/usr/bin/python’ -> ‘/usr/local/sbin/python-3.7/bin/python3’
[root@******* ~]# ll /usr/bin/ |grep python
//查看结果
-rwxr-xr-x. 1 root root 11312 Nov 14 00:00 abrt-action-analyze-python
lrwxrwxrwx. 1 root root 38 Mar 14 19:24 python -> /usr/local/sbin/python-3.7/bin/python3
lrwxrwxrwx. 1 root root 9 Mar 14 18:19 python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 Oct 31 07:46 python2.7
成功
服务器自带的sqlite版本很老 3.7.17
一步一步安装,然后让Python3.7能找到即可
wget https://sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
tar zxvf sqlite-autoconf-3280000.tar.gz
cd sqlite-autoconf-3280000
./configure
make && make install
之前Python编译安装的时候
LD_RUN_PATH=/usr/local/lib ./configure LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" --prefix=/usr/local/sbin/python-3.7
LD_RUN_PATH=/usr/local/lib make
目的就是让python3.7可以顺利找到新版本的sqlite
Python 3.7.0 (default, August 11 2019, 01:31:39)
[GCC 4.8.5 20150623 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.28.0'
>>> exit()
成功
直接将项目文件夹拖动到/home文件夹中,等待上传完成即可。
参考:
https://blog.csdn.net/u011798443/article/details/80881931
https://stackoverflow.com/questions/26261080/compile-python-3-4-with-sqlite3