服务器开发环境的配置

今天需要对服务器开发环境做配置,因为算是第一次做,因此做个记录方便以后的工作和学习。

一、查看服务器版本类型。linux如何查看版本,根据版本类型来进行服务器的配置。我的服务器是centos,因此暂时只讲红帽centos相关的配置流程,之后接触到其他服务器再做补充。

cat /proc/version    # 查看服务器的内核版本
cat /etc/redhat-release    # 查看服务器版本

lsb_release -a
-bash: lsb_release: command not found    # 由于lsb_release的缺失, 无法使用该命令,因此首先安装lsb_release, centos服务器使用yum安装软件

yum install -y redhat-lsb    # 安装lsb_release


$ lsb_release -a
"""
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.5.1804 (Core) 
Release:	7.5.1804
Codename:	Core
"""

二、安装python3

  1. 安装必要的库
    sudo yum install yum-utils -y;sudo yum groupinstall development -y;sudo yum install https://centos7.iuscommunity.org/ius-release.rpm -y
    
  2. 从安装源下载python安装包
    wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz    # 下载安装包
    tar -xzvf Python-3.7.1.tgz    # 对安装包进行解压
    

     

  3.  切入目录,安装编译工具,然后运行脚本

    cd Python-3.7.1
    sudo yum install gcc* glien* -y     
    ./configure --prefix=/sur/local/python3.7
    
    make
    make: *** No targets specified and no makefile found.  Stop.

     

  4. 逐步对报错信息做处理完成python3.7的安装

    yum -y install gcc gcc-c++ autoconf automake
    yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel 
    (尝试安装依赖,发现也没问题,没办法,重新执行./configure后发现,make可以正常使用了)
    
    sudo make
    sudo make install    
    (报错: ModuleNotFoundError: No module named '_ctypes')
    
    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
    
    yum install libffi-devel -y
    
    sudo make install    
    (完成python的安装)
    
    ln -s /usr/local/bin/python3.7 /usr/bin/python3
    ln -s /usr/local/bin/pip3.7 /usr/bin/pip3
    (为python3.7和pip3.7建立软连接)
    
    $ python3
    Python 3.7.1 (default, Mar 29 2019, 17:29:05) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> quit
    Use quit() or Ctrl-D (i.e. EOF) to exit
    >>> quit()
    
    (python3.7安装完成)
    
     

     

三、安装python3爬虫开发环境

(抓取库)
pip3 install requests
pip3 install scrapy
pip3 install selenium
pip3 install aiohttp

(解析库)
pip3 install lxml
pip3 install pyquery

(数据库存储)
pip3 install pymysql
pip3 install redis

(web库)
pip3 install flask
pip3 install tornado

(数据库)
# mysql:
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
rpm -Uvh [mysql...noarch.rpm]
yum install  -y  mysql-community-server

service mysqld start   # 启动mysql
service mysqld status    # 查看运行状态

grep 'temporary password' /var/log/mysqld.log    # 获取临时密码
mysql -uroot -p [临时密码]

ALTER USER 'root'@'localhost' IDENTIFIED BY '******';    # 修改密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '******' WITH GRANT OPTION;    # 授权其他机器登录
FLUSH  PRIVILEGES;


# redis:
yum -y install redis    # 安装
systemctl start redis    # 启动

vi /etc/redis.conf    # 打开redis配置文件,注释掉bind 127.0.0.1,取消注释requirepass foobared,并修改后面的字符串为你所要的密码,保存退出    ##vi查找命令:/[key] ##

systemctl restart redis    # 重启redis

 

你可能感兴趣的:(centos,linux)