Linux开发基础环境搭建

45次阅读

共计 1719 个字符,预计需要花费 5 分钟才能阅读完成。

服务器配置

免密登录,配置公钥连接

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

    $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.100.80

更换阿里 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 

正文完
 0