centOS7初体验

    xiaoxiao2025-09-17  1.0K+

    ●更改时区。

    // 查看时间和时区 timedatectl // 更改为北京时区 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime // 修改系统时区 sudo timedatectl set-timezone Asia/Shanghai

    ●ssh保活。

    编辑配置文件

    全局用户配置文件:/etc/ssh/ssh_config当前用户配置文件:~/.ssh/config

    在配置文件中,追加如下内容:

    Host * # client 每隔10秒给客户端发送一次保活信息包给客户端 ServerAliveInterval 10 # client 端发出的请求服务端没有回应的次数达到5次的时候就断开连接,正常情况下服务端都会相应 ServerAliveCountMax 5

    ●安装、更新gcc。

    gcc安装包https://ftp.gnu.org/gnu/gcc/

    yum install -y bzip2 // 安装 bzip2 wget https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.xz // 下载 tar -xvf gcc-8.2.0.tar.xz // 解压 cd gcc-8.2.0 ./contrib/download_prerequisites // 下载一些东西 mkdir build cd build ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib make // 这个很耗时,可能长达几小时,ssh别忘了后台运行,或保活 make install

    ●安装软件。

    yum install wget // wget可以从网上下载东西到当前目录。

    ●查看是否已经安装某软件。

    rpm -q vsftpd

    ●创建链接。

    ln -s ~/node-v9.3.0-linux-x64/bin/node /usr/bin/node

    ●后台运行程序。

    nohup command >/dev/null 2>&1 &

    ●启动关闭服务

    systemctl start httpd.service systemctl stop httpd.service systemctl restart httpd.service systemctl reload httpd.service systemctl status httpd.service

    ●将服务设置为开机启动

    systemctl enable httpd.service systemctl disable httpd.service

     

    ●更改root密码

    sudo passwd root

     

    ●添加新用户

    useradd -m baight passwd baight // 改密码

     

    ●给该用户添加sudo权限

    有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file.  This incident will be reported. 这里,xxx是用户名称,然后导致无法执行sudo命令,这时候,如下解决:

    1,添加文件的写权限。也就是输入命令。

    chmod u+w /etc/sudoers

    2,编辑/etc/sudoers文件。也就是输入命令"vi /etc/sudoers",进入编辑模式,找到这一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),然后保存退出。

    3,撤销文件的写权限。也就是输入命令。

    chmod u-w /etc/sudoers

     

    ●开机启动脚本

    在下边的文件中,追回你要执行的命令(或脚本)即可。

    /etc/rc.d/rc.local

    别忘了给脚本添加权限

    chmod +x /etc/rc.d/rc.local # 添加权限

    ●防火墙常用操作

    firewall-cmd --zone=public --add-port=80/tcp --permanent # 打开80端口的TCP firewall-cmd --zone=public --add-service=ftp --permanent # 打开ftp服务相关的端口 firewall-cmd --query-service http # 查询是否打开了http服务的相关端口 firewall-cmd --permanent --query-port=8080/tcp # 查询是否打开了8080端口 systemctl restart firewalld.service # 重启防火墙服务 systemctl stop firewalld.service # 关闭防火墙服务 systemctl disable firewalld.service # 永久关闭防火墙 firewall-cmd --permanent --query-port=8080/tcp # 查询是否打开了8080端口 systemctl restart firewalld.service # 重启防火墙服务 systemctl stop firewalld.service # 关闭防火墙服务 systemctl disable firewalld.service # 永久关闭防火墙

    命令含义:

    --zone #作用域

    --add-port=80/tcp  #添加端口,格式为:端口/通讯协议。add改为remove即为删除

    --permanent   #永久生效,没有此参数重启后失效

     

    ●关闭SELinux

    如果不关闭SELinux,会导致vsftpd服务,一直报500、550错误。

    sestatus -v // 查看SELinux状态 setenforce 0 // 临时关闭SELinu

    永久关闭SeLinux:

    修改/etc/selinux/config 文件

    将SELINUX=enforcing改为SELINUX=disabled,再重启计算机即可。

    ●安装MariaDB

    yum install mariadb mariadb-server mariadb-devel

     

    ●MariaDB设置Root密码

    mysqladmin -u root password newpass mysqladmin -u root password oldpass newpass // 当有老密码时

    ●MariaDB常用操作

    systemctl start mariadb #启动服务 systemctl enable mariadb #设置开机启动 systemctl restart mariadb #重新启动 systemctl stop mariadb.service #停止MariaDB

     

    ●安装python3

     

    方法一:该方法安装没有pip3工具

    yum install epel-release yum install python34

    方法二:

    安装依赖

    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make

    下载python3源码

    wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz

    解压刚下载的Python-3.5.2.tgz

    tar -zxvf Python-3.6.0.tgz

    进入到解压好的目录里边

    cd Python-3.6.0

    配置。“--prefix=/usr/local/python3”表示将python3安装到该目录。

    ./configure --prefix=/usr/local/python3

    编译并安装

    make && make install

    在/usr/bin中添加连接

    ln -s /usr/local/python3/bin/python3 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

    然后就可以使用python3了

     

    ●安装PyMySQL

    pip3 install pymysql

    下载源码https://github.com/PyMySQL/PyMySQL,并执行

    python3 setup.py install

     

     

    ●安装weex

    安装nodejs

     

    yum install nodejs

     

    安装openssl,不然会报“npm: relocation error: npm: symbol SSL_set_cert_cb, version libssl.so.10 not defined in file libssl.so.10 with link time reference”的错误。

     

      yum -y install openssl

     

    安装weex

     

    npm install -g weex-toolkit

     

     

     

     

     

     

     

    转载请注明原文地址: https://ju.6miu.com/read-1302755.html
    最新回复(0)