您的位置:首页 > 运维架构 > Linux

[linux学习笔记] 使用fedora20搭建开发环境

2014-12-25 00:33 866 查看
写前,先简要介绍下自己。07年毕业,至今7年有余,一直奋战在开发一线。2年前,由于项目原因和个人爱好,踏入linux阵营。从一个啥也不懂的菜鸟变成现在能初步使用linux搭建开发环境,中间也走了很多弯路。想借用此博客记录下一个初学linux的开发者走过的路,方便以后自己参考。如果能给其他兄弟启发和帮助,那更是极好的:)

先说硬件:如果只是尝试下linux系统,建议虚拟机(VMware或者VirtualBox),更彻底些,建议直接安装。

硬件没太多要求,最重要的一点(如果是笔记本),最好用单集显(只有一个集成显卡)的机器、再不济你用单独显(只有一个独立显卡),如果很不幸,你 的本子是个什么双显卡(集显+独显),请默哀10分钟,然后请慎重决定你是否愿意折腾(博主就是这种情况,一开始很痛苦,现在我换成了台式机,只有一个显卡了)。

再说linux发行版:种种原因,我选择的linux发行版是红帽系列。当然安装的也并不是rhel,最初安装的是centos6.x系列,系统非常稳定,但唯一的问题是内核版本太低,虽说可以自行编译内核什么的,但对于当初菜鸟现在依旧半瓶子水的博主来说,还是个麻烦的事情,最终选择的是fedora,中文不知道怎么读 (费多?肥多?肥多若?)差不多就行了吧。 对于RHEL、centos、fedora三者的来说,他们的关系可以说很深:Redhat的大名应该大家更熟悉些,他的企业版产品名字叫做 Red Hat
Enterprise Linux(简称RHEL),CentOS正是RHEL的克隆版本,两者几乎一样的为什么要克隆呢?牵扯到红帽公司的战略眼光和利益等等,这里不扯那么远,只需要知道一点,RHEL需要付费,CentOS无需付费,但同样也得不到任何有偿技术支持和升级服务。fedora可以说是红帽为了支持社区搞出来的另一个版本,一般大家习惯称之为红帽的桌面版本。 在fedora系列中,每半年会发行一个版本,使用的是当前最新的技术和软件版本,也有人将fedora称为红帽的试验田,也有一定的道理。简单可以说他们是一个大家族,RHEL是族长大哥,centos是二弟,fedora是他们家族前卫的小儿子。

就如写书一样,上面的可以当做序,时间紧张的同学可以略过,直接看下面。

1.安装系统

从fedora官网可以下载各种版本 的发行版,这里面临着第一个选择,选哪种桌面?GNOME/KDE,这个怎么说,萝卜白菜,各有所爱,反正我是选择了gnome桌面。系统的安卓可以使用光盘,U盘甚至硬盘,这个可以去自行度娘、狗狗。包括怎么分区之类的,网上的文章太多。

2.安装应用软件

2.1. 安装完系统第一件事情,就是给fedora选一个国内源。(所谓源,可以理解成类似于苹果神教的app商店)

国内可用的源很多。 网易、搜狐还有各大高校。我现在使用的中科大的源,虽然是教育网,也很快。http://mirrors.ustc.edu.cn/ 这里可以自己找

a.安装自动选择源插件。yum install yum-fastestmirror

b.安装多线程下载插件。yum install axel。还要下载axelget.conf 和axelget.py 这两个文件,随便下载到什么地方,然后拷贝到以下目录:

cp axelget.conf /etc/yum/pluginconf.d ; cp axelget.py /usr/lib/yum-plugins。 上述两个文件如果不拿梯子估计不好下载了。下面贴出来

axelget.conf

[main]
enabled=1
onlyhttp=1
enablesize=54000
cleanOnException=1


axelget.py

from yum.plugins import PluginYumExit, TYPE_CORE, TYPE_INTERACTIVE
from urlparse import urljoin
import os,time

requires_api_version = '2.3'
plugin_type = (TYPE_CORE, TYPE_INTERACTIVE)

enablesize=300000
trymirrornum=-1
maxconn=10
httpdownloadonly=False
cleanOnException=0

def init_hook(conduit):
global enablesize,trymirrornum,maxconn,cleanOnException,httpdownloadonly
enablesize = conduit.confInt('main','enablesize',default=30000)
trymirrornum = conduit.confInt('main','trymirrornum',default=-1)
maxconn = conduit.confInt('main','maxconn',default=10)
httpdownloadonly=conduit.confBool('main','onlyhttp',default=False)
cleanOnException=conduit.confInt('main','cleanOnException',default=0)
return

def predownload_hook(conduit):
global enablesize,cleanOnException,httpdownloadonly
preffermirror=""
PkgIdx=0
TotalPkg=len(conduit.getDownloadPackages())
for po in (conduit.getDownloadPackages()):
PkgIdx+=1
if hasattr(po, 'pkgtype') and po.pkgtype == 'local':
continue
totsize = long(po.size)
ret = False
if totsize <= enablesize:
conduit.info(2, "Package %s download size %d less than %d,Skip plugin!"  % (po.repo.id,totsize,enablesize))
continue
else:
conduit.info(2, "[%d/%d]Ok,we will try to use axel to download this big file:%d" % (PkgIdx,TotalPkg,totsize))
local = po.localPkg()
if os.path.exists(local):
if not os.path.exists(local+".st"):
fstate=os.stat(local)
if totsize == fstate.st_size:
conduit.info(2,"Target already exists,skip to next file!")
continue
localall = "%s %s" % (local,local+".st")
rmcmd = "rm -f %s" % (localall)
curmirroridx = 0
conduit.info(2,"Before we start,clean all the key files")
os.system(rmcmd)
connnum = totsize / enablesize
if connnum*enablesize<totsize:
connnum+=1
if connnum > maxconn:
connnum = maxconn
mirrors=[]
mirrors[:0]=po.repo.urls
if preffermirror != "":
mirrors[:0] = [preffermirror]
for url in mirrors:
if url.startswith("ftp://") and httpdownloadonly:
print "Skip Ftp Site:",url
continue
if url.startswith("file://"):
print "Skip Local Site:",url
continue
curmirroridx += 1
if (curmirroridx > trymirrornum) and (trymirrornum != -1):
conduit.info(2, "Package %s has tried %d mirrors,Skip plugin!" % (po.repo.id,trymirrornum))
break
remoteurl =  "%s/%s" % (url,po.remote_path)
syscmd = "axel -a -n %s %s -o %s" % (connnum,remoteurl,local)
conduit.info(2, "Execute axel cmd:\n%s"  % syscmd)
os.system(syscmd)
time.sleep(2)
if os.path.exists(local+".st"):
conduit.info(2,"axel exit by exception,let's try another mirror")
if cleanOnException:
conduit.info(2,"because cleanOnException is set to 1,we do remove key file first")
os.system(rmcmd)
continue
elif not os.path.exists(local):#this mirror may not update yet
continue
else:
ret = True
preffermirror=url
break
if not ret:
conduit.info (2,"try to run rm cmd:%s"  % rmcmd)
os.system(rmcmd)


弄完上面的一堆东西后,别忘了root权限下,执行 yum makecache,使之生效。

2.2.安装 桌面应用

yum install gnome-tweak-tool

主要是为了设置桌面和安装一些插件



然后是一些扩展:安装完成后,桌面的整体效果如下:(基本可以符合我的工作要求 :)



2.3.安装安装鼠标右键"在终端中打开":

yum install nautilus-open-terminal


2.4.一些必须安装的软件

yum install kernel-headers-$(uname -r) kernel-devel-$(uname -r)
yum install gcc


待续...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: