親身體驗!Fedora 18主要服務和系統設置
原創【51CTO原創稿件】Fedora 18剛剛推出不久,前文筆者先寫一些桌面方面的內容。下面看看在服務設置和系統管理內容。
一 系統初始化設置
1 升級安裝簡介
下面看看從Fedora 17升級到 Fedora 18的方法,首先備份系統。
- # yum update
- # reboot
- # yum install fedup
- # fedup-cli --network 18 --debuglog fedupdebug.log
- # reboot
GRUB 菜單選擇 "System Upgrade (fedup)" 即可。
說明:FedUp (FEDora UPgrader)是一個新的系統升級工具。
2 設置時區
首先顯示所有時區列表
- # timedatectl list-timezones
- Asia/Aden
- Asia/Almaty
- ……
設置一個自己的時區:
- #timedatectl set-timezone Asia/Shanghai
驗證一下
- #timedatectl status
如圖1 :
圖1:驗證一下時區設置
3 設置鍵盤
- #vi /etc/vconsole.conf
- # 修改為 to your keyboard rayouts
- KEYMAP="uk"
重新加載一下:
- #source /etc/vconsole.conf
4 命令行下修改編碼
首先顯示當前編碼:
- # echo $LANG
- en_US
如果修改為中文的話就是:
- vi /etc/locale.conf
- # 修改為
- LANG=" zh_CN.UTF-8"
- 重新加載一下
- #source /etc/locale.conf
5 輸入法快捷鍵設置
Fedora 18 搭載的 GNOME 3.6 默認使用 IBus 輸入法框架,但是沒有默認綁定輸入法切換快捷鍵,可以這樣設定快捷鍵: 在?“系?統?設?”置?中?的“區域和語言中的?輸?入?源”?選?項?下?點?擊?“快?捷?鍵?設?置”?鏈?接?,或?者?點?擊?頂?端?的?鍵?盤?圖?標?然?后?選?擇“快?捷?鍵?選?項”?,再?點?擊?左?側?面?板?的?輸?入?部?分?。?點?擊?切?換?至?下?一?輸?入?源?,然?后?按? CTRL + SPACE?。如圖2 。
圖2:輸入法快捷鍵設置
6 安裝資源監控工具glances
Glances是一款用于GNU/Linux、BSD和OS X 下的開源命令行系統監視工具,它使用Python開發。能夠監視CPU,負載,內存, i/0,網絡流量,文件系統,日志等 。
- # yum install python-pip python-devel gcc
- # pip-python install glances
- # glances(工作界面如圖3)
圖3 工作界面
#p#
二 主要服務設置
1 web服務器apache設置
安裝apache:
- #yum -y install httpd
修改配置文件:
- #vi /etc/httpd/conf/httpd.conf
- # line 261: 修改為Admin's address
- ServerAdmin root@cjh.net
- # line 275: 修改為ServerName www.cjh.net:80
- # line 330: 修改為
- Options FollowSymLinks ExecCGI
- # line 337: 修改為All,此時,所有具有".htaccess"作用域的指令都允許出現在.htaccess文件中。
- AllowOverride All
- # line 401: add file name that it can access only with directory's name
- DirectoryIndex index.html index.cgi index.php
- # line 758:注釋掉
- #AddDefaultCharset UTF-8
- # line 795: uncomment and add file-type that apache looks them CGI
- AddHandler cgi-script .cgi .pl .rb
啟動服務:
- #systemctl start httpd.service
- #systemctl enable httpd.service
測試一下html網頁:
- #vi /var/www/html/index.html
- <html>
- <body>
- <p style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
- Test Page
- </p>
- </body>
- </html>
使用瀏覽器查看一下,如圖4:
圖4:測試一下html網頁
測試一下cgi:
- #vi /var/www/html/index.cgi
- #!/usr/local/bin/perl
- print "Content-type: text/html\n\n";
- print "<html>\n<body>\n";
- print "<p style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\">\n";
- print "CGI Test Page";
- print "\n</p>\n";
- print "</body>\n</html>\n";
設置權限
- #chmod 705 /var/www/html/index.cgi
使用瀏覽器查看一下,如圖5:
圖5:測試一下cgi
安裝php相關軟件:
- #yum install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
啟動服務:
- #systemctl restart httpd.service
編寫一個文件測試一下:
- #vi /var/www/html/index.php
- <html>
- <body>
- <p style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
- <?php
- print Date("Y/m/d");
- ?>
- </p>
- </body>
- </html>
使用瀏覽器查看一下,如圖6:
圖6:測試一下php
安裝ruby語言:
Ruby,一種為簡單快捷的面向對象編程(面向對象程序設計)而創的腳本語言 。
- #yum -y install ruby
- #systemctl restart httpd.service
- #vi /var/www/html/index.rb
- #!/usr/bin/ruby
- print "Content-type: text/html\n\n"
- print "<html>\n<body>\n"
- print "<p style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\">\n"
- print Time.now.strftime('%Y/%m/%d')
- print "\n</p>\n"
- print "</body>\n</html>\n"
設置權限:
- #chmod 705 /var/www/html/index.rb
使用瀏覽器查看一下,如圖7 :
圖7:測試一下ruby
2 MYsql 安裝配置
- #yum install mysql mysql-server
- #systemctl start mysqld.service
- #systemctl enable mysqld.service
- # mysql -u root
下面設置密碼過程,如圖8:
- mysql>set password for root@localhost=password('password');
- Query OK, 0 rows affected (0.00 sec)
- mysql> exit
- #Bye
圖8:設置密碼過程
下面安裝mysql管理工具phpmyadmin:
- #yum -y install phpMyAdmin php-mysql php-mcrypt
修改配置文件:
- #vi /etc/httpd/conf.d/phpMyAdmin.conf
- # line 14: 添加IP 地址范圍
- Allow from 127.0.0.1 10.0.2.0/24
- # systemctl restart httpd.service
測試一下,如圖9:
圖9:mysql管理工具phpmyadmin
總結到此為止一個完成amp 服務配置完成 。
3 安裝日志管理工具Visitors
有很多開源和商業版的工具軟件可以對產生的Apache日志文件做分析和處理,通常的步驟是:
- 選取一個日志文件。
- 分析日志文件內容。
- 生成包含不同類別內容的統計信息網頁輸出。
Webalizer(http://www.mrunix.net/webalizer/)和AWStats (http://awstats.sf.net)是較為流行的日志文件分析工具;還有一些工具可以記錄來訪者具體訪問路線,比如Vistors和Pathalizer工具,可以分別從http://www.hping.org/visitors/和http://pathalizer.bzzt.net/下載。
下面看看Visitors的使用方法:
- #yum -y install graphviz
- #wget http://www.hping.org/visitors/visitors-0.7.tar.gz
- #tar zxvf visitors-0.7.tar.gz
- #cd visitors_0.7
- #make
- #cp visitors /usr/local/bin/
- #cd
- #mkdir /var/www/html/visitors
- #vi /etc/httpd/conf.d/visitors.conf
- # create new
- <Location /visitors>
- Order Deny,Allow
- Deny from all
- Allow from 10.0.0.0/24
- # IP address you allow
- </Location>
- #systemctl restart httpd.service
- #visitors -A /var/log/httpd/access_log -o html > /var/www/html/visitors/index.html
生產報告界面如圖10:
圖10:日志管理工具Visitors
4 dhcp服務設置簡介
安裝軟件包:
- #yum -y install dhcp
修改配置文件:
- #vi /etc/dhcp/dhcpd.conf
添加如下配置:
- # specify domain name
- option domain-name "cjh.net";
- # specify DNS's hostname or IP address
- option domain-name-servers dlp.cjh.net;
- # default lease time
- default-lease-time 600;
- # max lease time
- max-lease-time 7200;
- # this DHCP server to be declared valid
- authoritative;
- # specify network address and subnet mask
- subnet 10.0.0.0 netmask 255.255.255.0 {
- # specify the range of lease IP address
- range dynamic-bootp 10.0.0.200 10.0.0.254;
- # specify broadcast address
- option broadcast-address 10.0.0.255;
- # specify default gateway
- option routers 10.0.0.1;
- }
啟動服務:
- #systemctl start dhcpd.service
- #systemctl enable dhcpd.service
5 NFS服務設置簡介
?。?)服務器端設置
安裝軟件包:
- #yum -y install nfs-utils
修改配置文件:
- #vi /etc/idmapd.conf
- # line 5: uncomment and change to your domain name
- Domain =cjh.net
修改文件:
- #vi /etc/exports
- /home # shared directory
- 10.0.0.0/24 # range of networks NFS permits accesses
- rw # writable
- sync # synchronize
- no_root_squash # enable root privilege
- no_all_squash # enable users' authority
啟動服務:
- #systemctl start rpcbind.service
- #systemctl start nfs-server.service
- #systemctl start nfs-lock.service
- #systemctl start nfs-idmap.service
- #systemctl enable rpcbind.service
- #systemctl enable nfs-server.service
- #systemctl enable nfs-lock.service
- #systemctl enable nfs-idmap.service
?。?)客戶端設置
安裝軟件包:
- #yum -y install nfs-utils
修改配置文件:
- #vi /etc/idmapd.conf
- # line 5: uncomment and change to your domain name
- Domain =cjh.net
啟動服務:
- #systemctl start rpcbind.service
- #systemctl start nfs-server.service
- #systemctl start nfs-lock.service
- #systemctl start nfs-idmap.service
- #systemctl enable rpcbind.service
- #systemctl enable nfs-server.service
- #systemctl enable nfs-lock.service
- #systemctl enable nfs-mountd.service
掛載nfs目錄:
- #mount -t nfs dlp.cjh.net:/home /home
設置開機自動掛載:
- #vi /etc/fstab
- /dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
- UUID=65ec32e2-f459-4d63-b8b0-e18124b50f3a /boot ext4 defaults 1 2
- /dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
- #添加一行change home directory this server mounts to the one on NFS
- dlp.cjh.net:/home /home nfs defaults 0 0
總結:Fedora 18剛剛推出一周 ,筆者先寫了一些桌面方面的內容。本文介紹在服務設置和系統管理內容,另外讀者可以看看簡單體驗Fedora 18 Beta 一文,其中有網絡安全和系統管理方面的內容 。
【聲明】本文為51CTO原創稿件,轉載請注明作者和出處。































