[Translated] tech/30 Things to Do After Minimal RHEL or CentOS 7 Installation--1

This commit is contained in:
ictlyh 2015-04-25 20:08:14 +08:00
parent 1f74f0b42f
commit 4239b0e682
2 changed files with 216 additions and 217 deletions

View File

@ -1,217 +0,0 @@
Translating by ictlyh
30 Things to Do After Minimal RHEL/CentOS 7 Installation--1
================================================================================
CentOS is a Industry Standard Linux Distribution which is a derivative of RedHat Enterprise Linux. You may start using the OS as soon as you install it, but to make the most out of your system you need to perform a few updates, install a few packages, configure certain services and application.
This article aims at “30 Things to Do After Installing RHEL/CentOS 7”. The post is written keeping in mind you have installed RHEL/CentOS Minimal Install which is preferred in Enterprise and production environment, if not you can follow below guide that will show you minimal installations of both.
- [Installation of CentOS 7 Minimal][1]
- [Installation of RHEL 7 Minimal][2]
The following are the list of important things, which weve covered in this guide based on industry standard requirements. We hoping that, these things will be very helpful in setting up your server.
1. Register and Enable Red Hat Subscription
2. Configure Network with Static IP Address
3. Set Hostname of Server
4. Update or Upgrade CentOS Minimal Install
5. Install Command Line Web Browser
6. Install Apache HTTP Server
7. Install PHP
8. Install MariaDB Database
9. Install and Configure SSH Server
10. Install GCC (GNU Compiler Collection)
11. Install Java
12. Install Apache Tomcat
13. Install Nmap to Monitor Open Ports
14. FirewallD Configuration
15. Installing Wget
16. Installing Telnet
17. Installing Webmin
18. Enable Third Party Repositories
19. Install 7-zip Utility
20. Install NTFS-3G Driver
21. Install Vsftpd FTP Server
22. Install and Configure sudo
23. Install and Enable SELinux
24. Install Rootkit Hunter
25. Install Linux Malware Detect (LMD)
26. Server Bandwidth Testing with Speedtest-cli
27. Configure Cron Jobs
28. Install Owncloud
29. Enable Virtualization with Virtualbox
30. Password Protect GRUB
### 1. Register and Enable Red Hat Subscription ###
After minimal RHEL 7 installation, its time to register and enable your system to Red Hat Subscription repositories and perform a full system update. This is valid only if you have a valid RedHat Subscription. You need to register your in order to enable official RedHat System repositories and update the OS from time-to-time.
We have already covered a detailed instructions on how to register and active RedHat subscription at the below guide.
- [Register and Enable Red Hat Subscription Repositories in RHEL 7][3]
**Note**: This step is only for RedHat Enterprise Linux having a valid subscription. If you are running a CentOS server immediately move to further steps.
### 2. Configure Network with Static IP Address ###
The first thing you need to do is to configure Static IP address, Route and DNS to your CentOS Server. We will be using ip command the replacement of ifconfig command. However, ifconfig command is still available for most of the Linux distributions and can be installed from default repository.
# yum install net-tools [Provides ifconfig utility]
![Install ifconfig in Linux](http://www.tecmint.com/wp-content/uploads/2015/04/Install-ifconfig.jpeg)
But as I said we will be using ip command to configure static IP address. So, make sure you first check the current IP address.
# ip addr show
![Check IP Address i n CentOS](http://www.tecmint.com/wp-content/uploads/2015/04/Check-IP-Address.jpeg)
Now open and edit file /etc/sysconfig/network-scripts/ifcfg-enp0s3 using your choice of editor. Here, Im using Vi editor and make sure you must be root user to make changes…
# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
Now we will be editing four fields in the file. Note the below four fields and leave everything else untouched. Also leave double quotes as it is and enter your data in between.
IPADDR = “[Enter your static IP here]”
GATEWAY = “[Enter your Default Gateway]”
DNS1 = “[Your Domain Name System 1]”
DNS2 = “[Your Domain Name System 2]”
After making the changes ifcfg-enp0s3, looks something like the image below. Notice your IP, GATEWAY and DNS will vary, please confirm it with your ISP. Save and Exit.
![Network Details](http://www.tecmint.com/wp-content/uploads/2015/04/Network-Details.jpeg)
Network Details
Restart service network and check the IP is correct or not, that was assigned. If everything is ok, Ping to see network status…
# service network restart
![Restart Network Service](http://www.tecmint.com/wp-content/uploads/2015/04/Restarat-Network.jpeg)
Restart Network Service
After restarting network, make sure to check the IP address and network status…
# ip addr show
# ping -c4 google.com
![Verify IP Address](http://www.tecmint.com/wp-content/uploads/2015/04/Verify-IP-Address.jpeg)
Verify IP Address
![Check Network Status](http://www.tecmint.com/wp-content/uploads/2015/04/Check-Network-Status.jpeg)
Check Network Status
### 3. Set Hostname of Server ###
The next thing to do is to change the HOSTNAME of the CentOS sever. Check the currently assigned HOSTNAME.
# echo $HOSTNAME
![Check System Hostname](http://www.tecmint.com/wp-content/uploads/2015/04/Check-System-Hostname.jpeg)
Check System Hostname
To set new HOSTNAME we need to edit /etc/hostsname and replace old hostname with the desired one.
# vi /etc/hostname
![Set Hostname in CentOS](http://www.tecmint.com/wp-content/uploads/2015/04/Set-System-Hostname.jpeg)
Set System Hostname
After setting hostname, make sure to confirm hostname by logout and login again. After login check new hostname.
$ echo $HOSTNAME
![Confirm New Hostname](http://www.tecmint.com/wp-content/uploads/2015/04/Confirm-Hostname.jpeg)
Confirm New Hostname
Alternatively you may use command hostname command to view your current hotsname.
$ hostname
### 4. Update or Upgrade CentOS Minimal Install ###
This will not install any new packages other than updating and installing the latest version of installed packages and security updates. Moreover Update and Upgrade are pretty same except the fact that Upgrade = Update + enable obsoletes processing during updates.
# yum update && yum upgrade
![Update Minimal CentOS Server](http://www.tecmint.com/wp-content/uploads/2015/04/Update-CentOS-Server.jpeg)
Update Minimal CentOS Server
**Important**: You can also run the below command which will not prompt for the packages update and you do not need to type y for accepting the changes.
However it is always a good idea to review the changes which is going to take place on the sever specially in production. Hence using the below command may automate the update and upgrade for you but it is not recommended.
# yum -y update && yum -y upgrade
### 5. Install Command Line Web Browser ###
In most cases, specially in production environment, we usually install CentOS as command line with no GUI, in this situation we must have a commandline browsing tool to check websites via terminal. For this, we going to install a most famous tool called links.
# yum install links
![Install Commandline Browser](http://www.tecmint.com/wp-content/uploads/2015/04/Install-Commandline-Browser.jpeg)
Links: Commandline Web Browsing
For usage and examples to browse web sites u links tool, read our article [Command Line Web Browsing with Links Tool][4]
### 6. Install Apache HTTP Server ###
No matter for what purpose you will be using the server, in most of the cases you need a HTTP server to run websites, multimedia, client side script and many other things.
# yum install httpd
![Install Apache on CentOS](http://www.tecmint.com/wp-content/uploads/2015/04/Install-Apache-on-CentOS.jpeg.)
Install Apache Server
If you would like to change default port (80) of Apache HTTP Server to any other port. You need to edit the configuration file /etc/httpd/conf/httpd.conf and search for the line that starts typically like:
LISTEN 80
Change port number 80 to any other port (say 3221), save and exit.
![Change Apache Port on CentOS](http://www.tecmint.com/wp-content/uploads/2015/04/Change-Apache-Port.jpeg)
Change Apache Port
Add the port you just opened for Apache through firewall and then reload firewall.
Allow service http through firewall (Permanent).
# firewall-cmd add-service=http
Allow port 3221 through firewall (Permanent).
# firewall-cmd permanent add-port=3221/tcp
Reload firewall.
# firewall-cmd reload
After making all above things, now its time to restart Apache HTTP server, so that the new port number is taken into effect.
# systemctl restart httpd.service
Now add the Apache service to system-wide to start automatically when system boots.
# systemctl start httpd.service
# systemctl enable httpd.service
Now verify the Apache HTTP Server by using links command line tool as shown in the below screen.
# links 127.0.0.1
![Verify Apache Status](http://www.tecmint.com/wp-content/uploads/2015/04/Verify-Apache-Status.jpeg)
Verify Apache Status
--------------------------------------------------------------------------------
via: http://www.tecmint.com/things-to-do-after-minimal-rhel-centos-7-installation/
作者:[Avishek Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/centos-7-installation/
[2]:http://www.tecmint.com/redhat-enterprise-linux-7-installation/
[3]:http://www.tecmint.com/enable-redhat-subscription-reposiories-and-updates-for-rhel-7/
[4]:http://www.tecmint.com/command-line-web-browsers/

View File

@ -0,0 +1,216 @@
安装完最小化 RHEL/CentOS 7 后需要做的 30 件事情--1
================================================================================
CentOS 是一个工业标准的 Linux 发行版,是红帽企业版 Linux 的衍生版本。你安装完后马上就可以使用,但是为了更好地使用你的系统,你需要进行一些升级、软件包安装、配置特定服务和应用程序等操作。
这篇文章介绍了 “安装完 RHEL/CentOS 7 后需要做的 30 件事情”。阅读帖子的时候请牢记已经完成了 RHEL/CentOS 最小化安装,这是首选的企业和生产环境,如果还没有,你可以按照下面的指南,它会告诉你两者的最小化安装方法。
- [最小化安装 CentOS 7][1]
- [最小化安装 RHEL 7][2]
下面是一些重要的事情列表,基于工业标准需求我们都会进行介绍。我们希望这些东西在你配置服务器的时候能有所帮助。
1. 注册并启用红帽订阅
2. 使用静态 IP 地址配置网络
3. 设置服务器的主机名称
4. 更新或升级最小化安装的 CentOS
5. 安装命令行 Web 浏览器
6. 安装 Apache HTTP 服务器
7. 安装 PHP
8. 安装 MariaDB 数据库
9. 安装并配置 SSH 服务器
10. 安装 GCC (GNU 编译器集)
11. 安装 Java
12. 安装 Apache Tomcat
13. 安装 Nmap 检查开放端口
14. 配置防火墙
15. 安装 Wget
16. 安装 Telnet
17. 安装 Webmin
18. 启用第三方库
19. 安装 7-zip 工具
20. 安装 NTFS-3G 驱动
21. 安装 Vsftpd FTP 服务器
22. 安装和配置 sudo
23. 安装并启用 SELinux
24. 安装 Rootkit Hunter
25. 安装 Linux Malware Detect (LMD)
26. 用 Speedtest-cli 测试服务器带宽
27. 配置 Cron 作业
28. 安装 Owncloud
29. 启用 VirtualBox 虚拟化
30. 用密码保护 GRUB
### 1. 注册并启用红帽订阅 ###
RHEL 7 最小化安装完成后,是时候注册并启用系统红帽订阅库,以及执行一个完整的系统更新。这只当你有一个可用的红帽订阅时才能有效。你要注册才能启用官方红帽系统库并时不时进行操作系统更新。
在下面的指南中我们已经包括了一个如何注册并激活红帽订阅的详细说明。
- [在 RHEL 7 中注册并启用红帽订阅][3]
**注意**: 这一步仅适用于有一个有效订阅的红帽企业版 Linux. 如果你用的是 CentOS 服务器,请查看后面的章节。
### 2. 使用静态 IP 地址配置网络 ###
你第一件要做的事情就是为你的 CentOS 服务器配置静态 IP 地址,路由以及 DNS。我们会使用 ip 命令代替 ifconfig 命令。当然ifconfig 命令对于大部分 Linux 发行版来说还是可用的,还能从默认库安装。
# yum install net-tools [提供 ifconfig 工具]
![在 Linux 上安装 ifconfig](http://www.tecmint.com/wp-content/uploads/2015/04/Install-ifconfig.jpeg)
但正如我之前说,我们会使用 ip 命令来配置静态 IP 地址。所以,确认你首先检查了当前的 IP 地址。
# ip addr show
![在 CentOS 查看 IP 地址](http://www.tecmint.com/wp-content/uploads/2015/04/Check-IP-Address.jpeg)
现在用你的编辑器打开并编辑文件 /etc/sysconfig/network-scripts/ifcfg-enp0s3。这里我使用 Vi 编辑器,另外你要确保你是 root 用户才能保存更改。
# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
我们会编辑文件中的四个地方。注意下面的四个地方并保证不碰任何其它的东西。也保留双引号,在它们中间输入你的数据。
IPADDR = “[在这里输入你的静态 IP]”
GATEWAY = “[输入你的默认网关]”
DNS1 = “[你的域名系统 1]”
DNS2 = “[你的域名系统 2]”
更改了 ifcfg-enp0s3 之后,看起来像下面的图片。注意你的 IP网关和 DNS 可能会变化,请和你的 ISP(译者注:互联网服务提供商商) 确认。保存并退出。
![网络详情](http://www.tecmint.com/wp-content/uploads/2015/04/Network-Details.jpeg)
网络详情
重启网络服务并检查 IP 是否和分配的一样。如果一切都顺利,用 Ping 查看网络状态。
# service network restart
![重启网络服务](http://www.tecmint.com/wp-content/uploads/2015/04/Restarat-Network.jpeg)
重启网络服务
重启网络后,确认检查了 IP 地址和网络状态。
# ip addr show
# ping -c4 google.com
![验证 IP 地址](http://www.tecmint.com/wp-content/uploads/2015/04/Verify-IP-Address.jpeg)
验证 IP 地址
![检查网络状态](http://www.tecmint.com/wp-content/uploads/2015/04/Check-Network-Status.jpeg)
检查网络状态
### 3. 设置服务器的主机名称 ###
下一步是更改 CentOS 服务器的主机名称。查看当前分配的主机名称。
# echo $HOSTNAME
![查看系统主机名称](http://www.tecmint.com/wp-content/uploads/2015/04/Check-System-Hostname.jpeg)
查看系统主机名称
要设置新的主机名称,我们需要编辑 /etc/hostsname 文件并用想要的名称替换旧的主机名称。
# vi /etc/hostname
![在 CentOS 中设置主机名称](http://www.tecmint.com/wp-content/uploads/2015/04/Set-System-Hostname.jpeg)
在 CentOS 中设置主机名称
设置完了主机名称之后,务必注销后重新登录确认主机名称。登录后检查新的主机名称。
$ echo $HOSTNAME
![确认主机名称](http://www.tecmint.com/wp-content/uploads/2015/04/Confirm-Hostname.jpeg)
确认主机名称
你也可以用 hostname 命令查看你当前的主机名。
$ hostname
### 4. 更新或升级最小化安装的 CentOS ###
除了更新和安装已经有的软件的最新版本以及安全升级,这不会安装任何新的软件。总的来说更新和升级是相同的,除了事实上 升级 = 更新 + 更新时进行废弃处理。
# yum update && yum upgrade
![更新最小化安装的 CentOS 服务器](http://www.tecmint.com/wp-content/uploads/2015/04/Update-CentOS-Server.jpeg)
更新最小化安装的 CentOS 服务器
**重要**: 你也可以运行下面的命令,这不会弹出软件更新的提示,你也就不需要输入 y 接受更改。
然而,查看服务器上会发生的变化总是一个好主意,尤其是在生产中。因此使用下面的命令虽然可以为你自动更新和升级,但并不推荐。
# yum -y update && yum -y upgrade
### 5. 安装命令行 Web 浏览器 ###
大部分情况下,尤其是在生产环境中,我们通常用没有 GUI 的命令行安装 CentOS在这种情况下我们必须有一个能通过终端查看网站的命令行浏览工具。为了实现这个目的我们打算安装名为 links 的著名工具。
# yum install links
![安装命令行浏览器](http://www.tecmint.com/wp-content/uploads/2015/04/Install-Commandline-Browser.jpeg)
Links: 命令行 Web 浏览器
请查看我们的文章 [用 links 工具命令行浏览 Web][4] 了解用 links 工具浏览 web 的方法和例子。
### 6. 安装 Apache HTTP 服务器 ###
不管你因为什么原因使用服务器,大部分情况下你都需要一个 HTTP 服务器运行网站、多媒体、用户端脚本和很多其它的东西。
# yum install httpd
![在 CentOS 上安装 Apache](http://www.tecmint.com/wp-content/uploads/2015/04/Install-Apache-on-CentOS.jpeg.)
安装 Apache 服务器
如果你想更改 Apache HTTP 服务器的默认端口号(80)为其它端口,你需要编辑配置文件 /etc/httpd/conf/httpd.conf 并查找以下面开始的行:
LISTEN 80
把端口号 80 改为其它任何端口(例如 3221),保存并退出。
![在 CentOS 上更改 Apache 端口](http://www.tecmint.com/wp-content/uploads/2015/04/Change-Apache-Port.jpeg)
更改 Apache 端口
增加刚才分配给 Apache 的端口通过防火墙,然后重新加载防火墙。
允许 http 服务通过防火墙(永久)。
# firewall-cmd add-service=http
允许 3221 号端口通过防火墙(永久)。
# firewall-cmd permanent add-port=3221/tcp
重新加载防火墙。
# firewall-cmd reload
完成上面的所有事情之后,是时候重启 Apache HTTP 服务器了,然后新的端口号才能生效。
# systemctl restart httpd.service
现在添加 Apache 服务到系统层使其随系统自动启动。
# systemctl start httpd.service
# systemctl enable httpd.service
如下图所示,用 links 命令行工具 验证 Apache HTTP 服务器。
# links 127.0.0.1
![验证 Apache 状态](http://www.tecmint.com/wp-content/uploads/2015/04/Verify-Apache-Status.jpeg)
验证 Apache 状态
--------------------------------------------------------------------------------
via: http://www.tecmint.com/things-to-do-after-minimal-rhel-centos-7-installation/
作者:[Avishek Kumar][a]
译者:[ictlyh](https://github.com/ictlyh)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/centos-7-installation/
[2]:http://www.tecmint.com/redhat-enterprise-linux-7-installation/
[3]:http://www.tecmint.com/enable-redhat-subscription-reposiories-and-updates-for-rhel-7/
[4]:http://www.tecmint.com/command-line-web-browsers/