Linux开发基础环境搭建

码中飞翔 2019-11-04

服务器配置

免密登录,配置公钥连接

  1. 将本地的公钥复制到服务器

    $ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

更换阿里Yum源

  1. 更换Centos-7.repo

    wget http://mirrors.aliyun.com/repo/Centos-7.repo
    # 备份
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    
    mv Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo
    yum makecache 
    yum update

添加CentOS 7 EPEL仓库

  1. 安装一个第三方的yum源,这里用了Fedora的epel仓库

    $ sudo yum install epel-release

编译环境

  1. 安装编译环境

    yum groupinstall -y 'Development Tools'
    
    sudo yum install -y gcc gcc-c++ autoconf automake openssl openssl-devel curl curl-devel cmake cmake3 gdbm-devel re2c flex bison nano libtool libxml2-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel bzip2-devel libcurl-devel libicu-devel libwebp-devel libzip-dev zlib-devel

安装Git

  1. 安装git

    $ yum install -y git

安装nginx

  1. 安装Nginx

    yum install -y nginx
  2. 启动Nginx

    sudo systemctl start nginx.service
  3. 开机启动Nginx

    sudo systemctl enable nginx.service

安装Redis

  1. 安装Redis

    $ yum install redis
  2. 启动Redis

    $ service redis start
  3. 修改端口号/密码等配置

    $ vim /etc/redis.conf
  4. 测试登录

    $ redis-cli -h 127.0.0.1 -p 6379
  5. 设置开机自启动

    systemctl enable redis

安装MySQL

  1. 安装

    # 下载mysql源安装包
    $ wget http://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
    
    # 安装mysql源
    $ yum localinstall mysql80-community-release-el7-1.noarch.rpm
    
    # 安装mysql
    $ yum install mysql-community-server
    
    # 启动MySQL服务
    $ systemctl start mysqld
    $ systemctl status mysqld
    
    # 开机启动
    $ systemctl enable mysqld
    $ systemctl daemon-reload
    
    # 查看密码
    $ grep 'temporary password' /var/log/mysqld.log
    # 生成的密码root@localhost: kqeIpRI1pU-Dev
    
    # 登录
    $ mysql -uroot -p
    # 修改密码
    $ ALTER USER 'root'@'localhost' IDENTIFIED BY 'kqeIpRI1pU-Dev';

安装php

  1. 参考:https://webtatic.com/packages/php72/
  2. 安装PHP

    yum install epel-release
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    yum install php72w-fpm php72w-opcache
    yum install php72w-zts php72w-cli php72w-mysql php72w-mbstring php72w-xml php72w-gd php72w-devel
    
    yum install php72w-bcmath php72w-soap php72w-amqplib

相关推荐