基于ubuntu打造完美的开发环境

一、安装系统

1.下载最新的长期稳定版系统

如ubuntu18.04 LTS版

2.制作安装引导盘(使用u盘来制作)
3.安装系统

在安装时建议使用LVM这种分区方式

4.重启系统

安装完成后,请拨掉安装使用的u盘,并重启系统

二、基础设置

1.硬盘分区

如果只有一块硬盘,则不需要分区,因为安装的时候,已经分区,假如有另外一块硬盘/dev/sdb1

(1)通过fdisk来分区

  1. sudo fdisk /dev/sdb1 -l

根据交互命令行来操作,如果不知道如何分区,可以查阅相关资料

(2)格式化硬盘分区

  1. sudo mkfs -t ext4 /dev/sdb1

(3)将分区挂载到相关的目录中

  1. sudo mount -t ext4 /dev/sdb1 /opt
  • 如这里挂载到/opt目录中

(4)将分区信息写入配置中(永久保存分区挂载信息)

  1. vi /etc/fstab

添加以下内容:

  1. /dev/sdb1 /opt ext4 defaults 0 0
2.网络设置

默认情况下不需要设置网络,如果存在不能正常上网的情况下,可能需要设置IP地址、子网掩码、网关等,以及DNS设置,建议设置为114.114.114.114

3.输入法设置

默认只有英文和拼音两种,可以通过设置选项来添加更多的输入法(比如五笔)

三、软件安装

1.基础工具安装
  1. sudo apt-get install vim
  2. sudo apt-get install gcc
  3. sudo apt-get install g++
  4. sudo apt-get install make
  5. sudo apt-get install git
  6. sudo apt-get install net-tools

注:

  • vim区Linux的编辑器
  • gcc为c语言编译器
  • g++为c++的编译器
  • make为linux系统中的编译器
  • git为版本控制工具
  • net-tools为网络基础工具集
2.搭建开发环境
(1)安装openresty

安装基础类库

  1. sudo apt-get install libssl-dev
  2. sudo apt-get install libpcre3 libpcre3-dev
  3. sudo apt-get install zlib1g-dev
  • libssl是为了可以使用HTTPS功能
  • libpcre是为了可以使用正则表达式,主要是为了伪静态重写等
  • zlib将区本可以使用gzip压缩等
  1. wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
  2. tar -zxvf openresty-1.13.6.2.tar.gz
  3. cd openresty-1.13.6.2/
  4. ./configure --prefix=/usr/local/openresty
  5. make
  6. make install
  7. sudo ln -s /usr/local/openresty/bin/opm /usr/local/bin/opm
  8. sudo ln -s /usr/local/openresty/bin/resty /usr/local/bin/resty
  9. sudo ln -s /usr/local/openresty/bin/restydoc /usr/local/bin/restydoc
  10. sudo ln -s /usr/local/openresty/bin/restydoc-index /usr/local/bin/restydoc-index
  11. sudo ln -s /usr/local/openresty/bin/openresty /usr/local/bin/openresty
  12. sudo ln -s /usr/local/openresty/nginx/sbin/nginx /usr/local/bin/nginx
(2)安装MySQL
  1. sudo apt-get install mysql-server

通过系统账号登录,修改其他用户的密码

  1. sudo vim /etc/mysql/debian.cnf
  1. mysql -udebian-sys-maint -p
  2. set password for 'root'@'localhost' = password('123456');
  3. flush privileges;

注:mysql5.7及以上,使用下面的语句:

  1. update user set authentication_string = password('123456'), password_expired = 'N', password_last_changed = now() where user = 'root';

如果以上步骤还是不行,可以关闭密码验证:

  1. sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

添加一行:

  1. skip-grant-tables
  • 开发环境建议使用apt-get安装mysql
(3)安装PHP

安装必要的信赖包

  1. wget http://ftp.gnu.org/gnu/bison/bison-3.0.5.tar.gz
  2. tar -zxvf bison-3.0.5.tar.gz
  3. cd bison-3.0.5/
  4. ./configure
  5. make
  6. make install
  7. sudo apt-get install libssl-dev
  8. sudo apt-get install libxml2-dev
  9. sudo apt-get install libcurl4-openssl-dev
  10. sudo apt-get install libjpeg-dev
  11. sudo apt-get install libpng-dev
  12. sudo apt-get -y install libfreetype6-dev

编译安装PHP

  1. ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --enable-shared --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-mysqlnd
  2. make -j4
  3. make install

将PHP软链接到PATH目录中

  1. ln -s /usr/local/php/bin/php /usr/local/bin/php
(4)安装Redis
  1. make
  2. make PREFIX=/usr/local/redis install
  3. mkdir /usr/local/redis/etc
  4. mkdir /usr/local/redis/data
  5. mkdir /usr/local/redis/logs
  6. cp *.conf /usr/local/redis/etc
  7. ln -s /usr/local/redis/bin/redis-server /usr/local/bin/redis-server
  8. ln -s /usr/local/redis/bin/redis-cli /usr/local/bin/redis-cli
  9. sudo cp utils/redis_init_script /etc/init.d/redis

修改启动脚本

  1. sudo vim /etc/init.d/redis

将配置文件的所在位置修改为:/usr/local/redis/etc/redis.conf

(5)安装Node.js

建议下载二进制包

  1. ln -s /usr/local/node/bin/node /usr/local/bin/node
  2. ln -s /usr/local/node/bin/npm /usr/local/bin/npm
(6)安装python
  1. sudo apt-get install python
(7)安装Golang

建议下载go的二进制包

备用下载地址:https://studygolang.com/dl

(8)安装Java

建议下载java二进制包

下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html

3.安装常用工具软件

(1)SwitchHosts

官网下载:http://oldj.github.io/SwitchHosts/

制作桌面快捷方式:

  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=switchHosts
  4. Comment=switchHOsts
  5. Exec=/opt/switchHosts/switchHosts
  6. Icon=/opt/switchHosts/logo.png
  7. Categories=Application;Development;Java;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0

(2)Charles

  1. wget -q -O - https://www.charlesproxy.com/packages/apt/PublicKey | sudo apt-key add
  2. sudo sh -c 'echo deb https://www.charlesproxy.com/packages/apt/ charles-proxy main > /etc/apt/sources.list.d/charles.list
  3. sudo apt-get update
  4. sudo apt-get install charles-proxy

(3)moeditor

该软件是基于node开发的,因此需要node环境,而且node命令在环境变量PATH中

下地地址:https://github.com/Moeditor/Moeditor/releases

(4)notepad++

  1. sudo add-apt-repository ppa:notepadqq-team/notepadqq
  2. sudo apt-get update
  3. sudo apt-get install notepadqq
4.安装开发IDE

IDE破解:

  • 第一步:添加host-> 0.0.0.0 account.jetbrains.com
  • 第二步,输入序列号:
(1)phpstorm

phpstorm桌面快捷方式:

  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=phpstorm
  4. Comment=phpstorm
  5. Exec=/opt/phpstorm/bin/phpstorm.sh
  6. Icon=/opt/phpstorm/bin/phpstorm.png
  7. Categories=Application;Development;PHP;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
(2)webstorm

webstorm桌面快捷方式:

  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=webstorm
  4. Comment=webstorm
  5. Exec=/opt/webstorm/bin/webstorm.sh
  6. Icon=/opt/webstorm/bin/webstorm.png
  7. Categories=Application;Development;Javascript;HTML;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
(3)idea
  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=idea
  4. Comment=idea
  5. Exec=/opt/idea/bin/idea.sh
  6. Icon=/opt/idea/bin/idea.png
  7. Categories=Application;Development;Java;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
(4)goland
  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=goland
  4. Comment=goland
  5. Exec=/opt/goland/bin/goland.sh
  6. Icon=/opt/goland/bin/goland.png
  7. Categories=Application;Development;golang;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
(5)pycharm
  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=pycharm
  4. Comment=pycharm
  5. Exec=/opt/pycharm/bin/pycharm.sh
  6. Icon=/opt/pycharm/bin/pycharm.png
  7. Categories=Application;Development;python;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
(6)rubymine
  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=rubyMine
  4. Comment=rubyMine
  5. Exec=/opt/rubymine/bin/rubymine.sh
  6. Icon=/opt/rubymine/bin/rubymine.png
  7. Categories=Application;Development;ruby;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
(7)clion
  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=clion
  4. Comment=clion
  5. Exec=/opt/clion/bin/clion.sh
  6. Icon=/opt/clion/bin/clion.png
  7. Categories=Application;Development;C;C++;IDE
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
5.其他开发工具
(1)navicat

下地地址:https://www.navicat.com.cn/download/navicat-premium

  1. vim start_navicat
  1. export LANG=”zh_CN.UTF-8

桌面快捷方式:

  1. [Desktop Entry]
  2. Encoding=UTF-8
  3. Name=navicat
  4. Comment=navicat
  5. Exec=/opt/navicat/start_navicat
  6. Icon=/opt/navicat/logo.png
  7. Categories=Application;Development;MySQL;
  8. Version=1.0
  9. Type=Application
  10. Terminal=0
(2)postman

postman在ubuntu软件商城中就有,搜索安装即可

6.办公娱乐软件
(1)微信
(2)钉钉
(3)QQ

四、系统美化

这里推荐使用deepin(深度系统)的一些组件,为什么不用直接使用deepin系统呢,为了追求稳定性,建议还是先使用ubuntu吧

1.下载安装终端:deepin-terminal
  1. sudo apt-get install deepin-terminal
2.下载安装桌面:deepin-desktop
  1. sudo add-apt-repository -r ppa:leaeasy/dde
  2. sudo add-apt-repository ppa:leaeasy/dde
  3. sudo apt-get update
  4. sudo apt-get install dde
3.添加deepin镜像源

修改 /etc/apt/sources.list

  1. deb [by-hash=force] http://packages.deepin.com/deepin unstable main contrib non-free
  2. # deb-src http://packages.deepin.com/deepin unstable main contrib non-free
  3. deb http://packages.deepin.com/deepin trusty main non-free universe
  4. # deb-src http://packages.deepin.com/deepin trusty main non-free universe
4.安装deepin商店
  1. sduo apt-get install grub2-theme-deepin
  2. sudo apt-get install deepin-appstore
4.问题集锦

(1)没有公钥的情况:

  1. gpg --keyserver keyserver.ubuntu.com --recv-key 425956BB3E31DF51
  2. gpg --export --armor 425956BB3E31DF51 | sudo apt-key add -

注:425956BB3E31DF51为实际的公钥