温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

安装完CentOS 7 Minimal之后如何打造桌面工作环境

发布时间:2021-11-15 16:17:00 来源:亿速云 阅读:202 作者:小新 栏目:云计算

小编给大家分享一下安装完CentOS 7 Minimal之后如何打造桌面工作环境,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

安装完CentOS 7 Minimal之后,从头打造桌面工作环境

U盘装CentOS 7 DVD版不能引导的解决办法

更改root密码

SSH登录

增加除root之外的常规用户

装完CentOS 7之后,以前装好的win7或是其它系统没有出现在启动项中的解决办法

启动桌面环境

设置是否默认启动桌面环境

没有ifconfig命令的解决办法

网络配置

DNS工具与Windows一样

安装第三方源(EPEL和RPMForge)

安装C++编译器

挂载NTFS文件系统

安装VirtualBox

安装Markdown解析器(python-markdown)

安装Flash Player

安装wkhtmltopdf

安装MPlayer

配置GoAgent

安装配置管理Git

安装配置管理Apache HTTP Server(httpd)

安装配置管理MySQL(MariaDB)

安装配置管理PHP

Linux(Yum系)常用压缩打包命令

Yum和RPM常用命令备忘录

制作bash脚本

Hard Link(硬链接)

Symbolic Link(符号链接、软链接)

查找文件

常用配置文件

改变Aptana Rubles文件夹默认在家目录的解决办法

GNOME配置

U盘装CentOS 7 DVD版不能引导的解决办法

用UltraISO将DVD版的iso刻录到U盘后,删除packages文件夹(节省空间,不删除亦可),将iso文件复制进U盘根目录,开机之后出现

dracut:/#

输入命令

$ cd dev
$ ls

找到U盘的盘符,比如sda5,然后重新开机,按方向键选择到第一项Install CentOS 7,按下Tab键,出现

vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet

修改为

vmlinuz initrd=initrd.img repo=hd:/dev/sda5:/ quiet

更改root密码

用root账户登录shell,Alt+(F1~F6)切换tty1~tty6。

# passwd

SSH登录

$ ssh root@SERVER_IP_ADDRESS

增加除root之外的常规用户

# useradd newusername
# passwd newusername

装完CentOS 7之后,以前装好的win7或是其它系统没有出现在启动项中的解决办法

在/boot/grub2/grub.cfg中添加

menuentry 'Windows 7 Professional' {
    set root=(hd0,1)
    chainloader +1
}

(hd0,1)代表第一个分区。

安装GNOME桌面环境

# yum grouplist
# yum groupinstall "GNOME Desktop"

CentOS 6.x与CentOS 7的yum group是不同的,CentOS 6.x需要这样

# yum groupinstall "X Window System" "Desktop" "Chinese Support"

启动桌面环境

# startx

设置是否默认启动桌面环境

$ vi /etc/inittab

/etc/inittab文件明确声明了inittab is no longer used when using systemd,并指示了如何用systemd的方式来做。

# systemctl get-default
# systemctl set-default multi-user.target
# systemctl set-default graphical.target

没有ifconfig命令的解决办法

如果没有安装桌面环境,那么minimal版本没有ifconfig命令。

找出哪个包提供了ifconfig命令

# yum provides ifconfig

# yum whatprovides ifconfig

输出中可以看到net-tools包提供了ifconfig命令。

# yum install net-tools

网络配置

$ ifconfig -a 
# ifconfig enp0s3 up // 开启enp0s3网卡
# ifconfig enp0s3 down // 关闭enp0s3网卡
$ dhclient enp0s3 // 发送DHCP请求

DNS工具与Windows一样

$ nslookup

安装第三方源(EPEL和RPMForge)

CentOS官方文档声称严重推荐EPEL,不推荐RPMForge,因为RPMForge已经不再被维护了,虽然曾经被CentOS推荐。

EPEL

官方网站http://fedoraproject.org/wiki/EPEL

EL7下载地址http://download.fedoraproject.org/pub/epel/7/x86_64/repoview/epel-release.html

# rpm -ivh epel-release-7-5.noarch.rpm

EPEL的repo文件已经在目录/etc/yum.repos.d/下。

RPMForge

官方网站http://repoforge.org/

EL7下载地址http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

# rpm -ivh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

RPMForge的repo文件已经在目录/etc/yum.repos.d/下。

安装C++编译器

# yum install gcc-c++

挂载NTFS文件系统

CentOS自身的源里没有支持NTFS的包,需要从EPEL或RPMForge(也叫RepoForge)源里安装。

# yum install ntfs-3g --enablerepo=epel

# yum install fuse-ntfs-3g --enablerepo=rpmforge

安装VirtualBox

VirtualBox要编译内核,所以需要kernel-devel这个包。

# yum install kernel-devel
# yum localinstall *.rpm

对于VirtualBox只能装32位系统的情况,涉及到Host的CPU是否支持虚拟化以及是否开启了虚拟化,如果没有开启,在BIOS里面设置,一般在CPU的子设置里面,且含有“Virtualization”或“Virtual”字样,将它设为Enable

安装Markdown解析器(python-markdown)

Linux下Markdown解析器有很多,CentoOS官方Yum源(extras)里有python-markdown。

# yum install python-markdown

python-markdown的命令名是markdown_py,查看帮助。

$ markdown_py -h

用法简单,举例说明,用以备忘。

  • 解析*.md,输出html内容到stdout。

    $ markdown_py *.md


  • 解析*.md,利用重定向,输出html内容到*.html。

    $ markdown_py *.md > *.html


  • 可以不使用重定向,利用markdown_py命令的-f选项,输出html内容到*.html。

    $ markdown_py -f *.html *.md


  • -o选项用来指定解析完之后html的输出格式,可以是html5html4xhtml1,默认xhtml1,所以最好明确指定-o选项。

    $ markdown_py -o html5 *.md > *.html


安装Flash Player

  • adobe官网下载yum安装包

    # rpm -ivh *.rpm
    # yum install flash-plugin --enablerepo=adobe-linux-x86_64


  • adobe官网下载rpm安装包

    # rpm -ivh *.rpm


  • 利用RPMforge

    # yum install flash-plugin --enablerepo=rpmforge


安装wkhtmltopdf

RPMforge(现在叫RepoForge)的repo中没有CentOS 7的smplayer,所以需要源代码安装。

安装MPlayer通常需要以下3个东西:

  • source code(源代码tarball文件)

  • binary codecs(一堆二进制的解码器文件)

  • a skin(皮肤)

官网下载source code。

$ ./configure --enable-gui --language=zh_CN --disable-ossaudio

--enable-gui告诉configure以后运行MPlayer需要图形界面,不仅只从command line运行。

--language=zh_CN告诉configure安装中文环境。

--disable-ossaudio是因为linux2.4以后的内核逐渐抛弃oss音频架构而转向alsa(详细说明请参考http://blog.csdn.net/meizum10/article/details/17437959)。

提示No FFmpeg checkout, press enter to download one with git or CTRL+C to abort,按下回车键。

通常configure会失败,因为需要一些依赖。它告诉缺什么就装什么。

提示./configure: line 1522: git: command not found Failed to get a FFmpeg checkout,configure需要利用git下载ffmpeg,如果git没有安装,那么就安装git。

# yum install git

提示Error: Compiler is not functioning correctly. Check your installation and custom CFLAGS .,源代码编译安装当然需要gcc,如果没有安装,那么就安装它。g++依赖于gcc,所以为了以后省事,干脆安装g++。

# yum install gcc-c++

提示Error: yasm not found, use --yasm='' if you really want to compile without,缺少yasm,去yasm官网http://yasm.tortall.net下载源代码tarball,简单的三步走:

$ ./configure
$ make
$ su
# make install

In function avcodec_register_all' 提示Error: The GUI requires X11.`,缺少X11,yum安装gtk2-devel,注意要安装gtk2-devel,gtk3-devel不行

# yum install gtk2-devel

configure通过,接着

$ make
$ su
# make install

OK,安装完成,在command line里运行mplayer 媒体文件名一般可以播放。

官网下载binary codecs,是个tarball,解压,得到一堆解码器文件,将这些解码器文件放到/usr/local/lib/codecs/里。/usr/local/lib/下如果没有codecs文件夹,那就手动创建一个。

官网下载skin文件(我安装的是clearplayer),是个tarball,解压,得一文件夹,将这文件夹放到/usr/local/share/mplayer/skins/里,之后建立一个叫default的符号链接,指向皮肤文件夹。

# ln -s <文件夹名字> default

当然,也可以把文件夹名字直接改成default。

如果播放没有声音,那么就这么干:

# yum install *alsa*

安装了一堆alsa相关的东西。

至于CentOS 6.x,RPMforge(现在叫RepoForge)的CentOS 6.x的repo中有smplayer,所以直接yum安装。

# yum install smplayer --enablerepo=rpmforge

配置GoAgent

服务端上传:

$ python server/uploader.py // linux & mac
双击server/uploader.bat // windows

客户端运行:

$ python local/proxy.py // linux & mac
双击local/goagent.exe // windows

Firefox和Opera需要导入证书。

对于CentOS 6.x:

# yum install centos-release-SCL
# yum install python27

在/etc/ld.so.conf.d/文件夹中建立文件python27.conf,内容为/opt/rh/python27/root/usr/lib64。

# ldconfig // 加载配置
$ /opt/rh/python27/root/usr/bin/python proxy.py

安装配置管理Git

安装
# yum install git
git config

安装完需要用git config配置user name和user email,否则不能commit。

$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
$ git config --list

git config有3种选项,对应不同配置文件。

  1. --system /etc/gitconfig

  2. --global ~/.gitconfig

  3. no option .git/config

SSH KEY

为了使用GitHub的SSH keys功能,利用ssh-keygen工具在本地生成rsa密钥对。

$ ssh-keygen -t rsa -C "your_email@example.com" // generate a rsa key pair in the file ~/.ssh/id_rsa & ~/.ssh/id_rsa.pub
$ ssh-keygen -p //adding or changing a passphrase
.gitignore

各种类型的gitignore模板https://github.com/github/gitignore

# 此为注释
*.a 忽略所有目录下.a结尾的文档
!lib.a 但不忽略lib.a文档
*.[oa] 忽略所有目录下.a或.o结尾的文档
*~ 忽略所有目录下~结尾的文档
TODO 忽略所有目录下的TODO文档
/TODO 仅仅忽略根目录下的TODO文档
build/ 忽略所有目录下的build文件夹
/build/ 仅仅忽略根目录下的build文件夹
doc/**/*.txt 忽略doc文件夹下的所有.txt文档
星号*匹配零个或多个任意字符
[abc] 匹配任何一个列在方括号中的字符(这个例子要么匹配一个 a,要么匹配一个 b,要么匹配一个 c)
问号?只匹配一个任意字符
如果在方括号中使用短划线分隔两个字符,表示所有在这两个字符范围内的都可以匹配,比如 [0-9] 表示匹配所有 0 到 9 的数字
常用命令
$ git init
$ git add *
$ git commit -m 'message'

$ git status
$ git status -s
$ git status --short

$ git diff

$ git clone git@github.com:who/whatrepo.git
$ git clone https://github.com/who/whatrepo
$ git clone https://github.com/who/whatrepo SpecifiedFolder

$ git remote
$ git remote -v
$ git remote add [shortname] [url]
$ git remote rm [remote-name]
$ git remote rename [old-name] [new-name]
$ git remote fetch [remote-name]
$ git push [remote-name] [branch-name]
$ git pull

安装配置管理Apache HTTP Server(httpd)

安装
# yum install httpd
管理

在Windows下,httpd是以系统服务的形式运行,在Unix(Linux)下,httpd作为daemon(守护进程)运行。

httpd官方文档推荐用apachectl这个script来调用httpd可执行程序,原因是:apachectl首先会设置一些为保证httpd正确运行所必要的环境变量,然后再去调用httpd可执行程序,而且apachectl会把命令行参数原封不动的传递给httpd。

apachectl是httpd daemon的front end。所以管理员应该用apachectl来管理httpd daemon

apachectl在CentOS 6.x和CentOS 7下均可用。

# apachectl start
# apachectl stop或graceful-stop
# apachectl restart或graceful
# apachectl status

如果不使用apachectl这个script,也可以使用service这个管理daemon的命令。

# service httpd start
# service httpd stop
# service httpd restart
# service httpd status

如果系统支持systemd(CentOS 7开始支持systemd),既可以用service命令,也可以用systemd。

# systemctl start httpd.service
# systemctl stop httpd.service
# systemctl restart httpd.service
# systemctl status httpd.service
# systemctl is-active httpd.service
设置开机自动启动

要设置开机自动启动httpd,需要区分在CentOS 6.x和CentOS 7下2种情况。

CentOS 6.x没有systemd,我最喜欢的方式是修改/etc/rc.d/rc.local这个文件。

# vi /etc/rc.d/rc.local

添加以下命令。

/usr/sbin/apachectl start

CentOS 7用了systemd。

# systemctl enable httpd.service
# systemctl disable httpd.service
理解并设置虚拟主机

httpd的主配置文件是/etc/httpd/conf/httpd.conf。目录/etc/httpd/conf.d/下的文件只要以.conf作为扩展名,其内容就能被集成到主配置文件中。所以尽量不直接修改主配置文件,而是在目录/etc/httpd/conf.d/下面搞。

httpd官方文档把Virtual Host(虚拟主机)分为了2种:IP-based和Name-based。

我的理解是:

在配置文件里放一个<VirtualHost></VirtualHost> block,就代表配置了一个Virtual Host,放2个就代表配置了2个。起始标签<VirtualHost>里需要说明IP地址和端口,即这个样子<VirtualHost 192.168.1.1:80>,IP可以是*,端口可以不写。

一个request来了之后,就根据IP地址和端口按照配置文件中的顺序来一个个匹配<VirtualHost></VirtualHost> block。如果所有的<VirtualHost></VirtualHost> block都没匹配上,那么就去咨询主配置文件里的指示了。而一旦某些<VirtualHost></VirtualHost> block匹配上了,那么只有这些匹配上的block才能成为request的候选者,其它的<VirtualHost></VirtualHost> block包括主配置文件就都没有机会了。

如果候选者只有1个,那么没的挑了,就是你了。而如果候选者有多个,怎么选?

就得看<VirtualHost></VirtualHost> block里面的ServerNameServerAlias指示了,谁的ServerNameServerAlias与request的HTTP报文的header的Host相匹配,那么谁就胜出。如果多个block都匹配,那么先来后到,谁在前边谁胜出。如果都不匹配,那么还是先来后到。

Listen 80
<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName www.example.com
    ServerAlias example.com 
</VirtualHost>
<Directory "/var/www/html">
    AllowOverride All
</Directory>

AllowOverride All的作用是使web目录内的.htaccess文件起作用,常用于开启Drupal的简洁URL。

如果VirtualHost指定了端口,需要写上Listen指示,因为只有先告诉httpd监听某个端口,request才能从这个端口进来,进而进入某个VirtualHost。httpd主配置文件默认已经配置了Listen 80,所以VirtualHost如果指定80端口,就不需要再此指示监听80端口了,配置文件里重复的指示不符合语法。

安装配置管理MySQL(MariaDB)

安装

MySQL

# yum install mysql-server

MariaDB

# yum install mariadb-server

mysql-server package依赖于mysql package,所以没必要这么做:yum install mysql mysql-server

管理
MySQL
# service mysqld start
# service mysqld stop
# service mysqld restart
# service mysqld status
MariaDB
# service mariadb start
# service mariadb stop
# service mariadb restart
# service mariadb status

也可以用systemd方式

# systemctl start mariadb.service
# systemctl stop mariadb.service
# systemctl restart mariadb.service
# systemctl status mariadb.service
# systemctl is-active mariadb.service
配置
# mysql_secure_installation

# mysqladmin -u root password ''
设置开机自动启动
MySQL
# vi /etc/rc.d/rc.local

添加以下命令

/usr/sbin/service mysqld start
MariaDB
# systemctl enable mariadb.service
# systemctl disable mariadb.service
登录
$ mysql -hhost -Pport -Ddatabase -uusername -p
登录后的常见命令
> create database if not exists * default character set utf8;
> show databases;
> use *;
> show tables;

安装配置管理PHP

安装
# yum install php

仅仅安装PHP往往是不够的,通常还需要安装模块。

# yum install php-mysql
# yum install php-gd
# yum install php-xml
# yum install php-mbstring
配置

PHP配置文件

/etc/php.int

通常需要改配置文件

upload_max_filesize = 2M

Linux(Yum系)常用压缩打包命令

.tar.gz

$ tar xzvf *.tar.gz
$ tar czvf *.tar.gz file1 file2

.tar.bz2

$ tar xjvf *.tar.bz2
$ tar cjvf *.tar.bz2 file1 file2

.tar.xz

$ tar xJvf *.tar.xz
$ tar cJvf *.tar.xz file1 file2

.zip

# yum install zip unzip
$ zip *.zip file1 file2
$ unzip *.zip

.rar

# yum install rar --enablerepo=rpmforge
$ rar a *.rar file1 file2
$ rar x *.rar

.7z

# yum install p7zip --enablerepo=rpmforge
$ 7za a *.7z file1 file2
$ 7za x *.7z

Yum和RPM常用命令备忘录

yum history

# yum history
# yum history list <ID>
# yum history info <ID>
# yum history undo <ID>
# yum history redo <ID>

yum update

# yum clean all
# yum makecache
# yum update

rpm安装卸载

# rpm -ivh *.rpm
# rpm -qa
# rpm -qa|grep *
# rpm -e *
# rpm -e * --nodeps

制作bash脚本

#!/bin/bash
write cmd line here
# comment

Hard Link(硬链接)

$ ln target_file link_file

Symbolic Link(符号链接、软链接)

$ ln -s target_file link_file

查找文件

$ find / -name "*"

常用配置文件

/etc/resolv.conf
/etc/hosts
/etc/inittab
/etc/yum.repos.d/
~/.config/user-dirs.dirs
~/.bash_profile

改变Aptana Rubles文件夹默认在家目录的解决办法

eclipse.ini文件中,在-vmargs之后添加

-Dstudio.rubleUserLocation=Aptana Rubles

GNOME配置

$ gnome-tweak-tool

看完了这篇文章,相信你对“安装完CentOS 7 Minimal之后如何打造桌面工作环境”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI