Professional Documents
Culture Documents
Cent OS6
Cent OS6
CentOS 6
21-23 2555
CentOS 5.2
sothorn@gmail.com
CentOS RHEL
CentOS 5
MySQL CentOS
sothorn@gmail.com
http://linux.sothorn.org
CentOS 6 sothorn@gmail.com
1 CentOS 6
2 RPM YUM
3 DNS (Domain Name System)
4 MySQL
5 Apache+PHP
6 phpMyAdmin
7 Postfix Mail Server
8 roundcubemail
1
22
34
40
48
52
54
56
CentOS 6 sothorn@gmail.com
1 CentOS 6
/boot
RHEL 6
CentOS 6
/boot partition (250 MB)
root (/) partition (3.0 GB - 5.0 GB) 8-18 GB
/tmp 256 512 MB
/var
/home
Swap Swap CentOS 6 Swap
Amount of RAM in the System
CentOS 6 sothorn@gmail.com
CentOS 6
DVD CentOS 6 Install or upgrade an existing
system
Skip
CentOS 6 sothorn@gmail.com
Next
CentOS 6 sothorn@gmail.com
CentOS 6 sothorn@gmail.com
Re-Initialize all
DNS server ns
ns1.companyname.com
CentOS 6 sothorn@gmail.com
Configure Network
System eth0 Edit...
CentOS 6 sothorn@gmail.com
user root
CentOS 6 sothorn@gmail.com
Create
CentOS 6 sothorn@gmail.com
Standard Partition
250 M
CentOS 6 sothorn@gmail.com
10
/ 18 GB
/tmp 512 MB
CentOS 6 sothorn@gmail.com
11
swap
4 GB
/var
Fill to maximum allowable size
CentOS 6 sothorn@gmail.com
12
/var Primary
/var Edit
CentOS 6 sothorn@gmail.com
13
/var Primary
Next
CentOS 6 sothorn@gmail.com
14
format
CentOS 6 sothorn@gmail.com
15
Next
Package
Customize now
CentOS 6 sothorn@gmail.com
16
Base System
Server
CentOS 6 sothorn@gmail.com
17
Web Service
CentOS 6 sothorn@gmail.com
18
Desktops
Desktops()
CentOS 6 sothorn@gmail.com
19
Applications
Development
CentOS 6 sothorn@gmail.com
20
Languages Thai
Server
CentOS 6 sothorn@gmail.com
21
CentOS 6
SELinux
SELinux /etc/selinux/config
#ThisfilecontrolsthestateofSELinuxonthesystem.
#SELINUX=cantakeoneofthesethreevalues:
#enforcingSELinuxsecuritypolicyisenforced.
#permissiveSELinuxprintswarningsinsteadofenforcing.
#disabledNoSELinuxpolicyisloaded.
SELINUX=disabled
#SELINUXTYPE=cantakeoneofthesetwovalues:
#targetedTargetedprocessesareprotected,
#mlsMultiLevelSecurityprotection.
SELINUXTYPE=targeted
Firewall
Firewall
#setup
#serviceiptablesstop
#chkonfigiptablesoff
CentOS 6 sothorn@gmail.com
22
2 RPM YUM
C source code
3 ./configure, make, make install
Debain ubuntu apt-get, Red Hat rpm (RPM Package Manager)
rpm
RPM
name
version
release
architecture
noarch
Package
mysql-server-5.0.45-7.el5.i386.rpm
package mysql-server
version
5.0.45-7
release
el5
architecture i386
setup-2.5.58-1.el5.noarch.rpm
noarch CPU
package ()
nstall: rpm -i
Upgrade: rpm -U
Freshen: rpm -F
/
Erase: rpm -e
CentOS 6 sothorn@gmail.com
23
rpm Query
rpm -q what_package what_information
-q query
-f
-p .rpm
-i
-l
rpm query
rpm -qa Package
CentOS 6 sothorn@gmail.com
24
Package
CentOS 6 sothorn@gmail.com
25
CentOS 6 sothorn@gmail.com
26
YUM
Yellow dog Updater, Modified (YUM)
( / / ) RPM GNU General Public License
Seth Vidal yum
Pup, Pirut ,Yumex, Yum Extender KYum Seth Vidal Red Hat
yum Red Hat
Yum Yellowdog Updater (YUP) Yellow Dog Linux Red Hat
YUM
Yum :
(multiple repositories)
depency
CentOS 6 sothorn@gmail.com
27
yum
yum info
CentOS 6 sothorn@gmail.com
28
yum deplist
CentOS 6 sothorn@gmail.com
29
yum install
CentOS 6 sothorn@gmail.com
30
yum remove
CentOS 6 sothorn@gmail.com
31
yum update
yum update
# yum update xterm
yum
CentOS 6 sothorn@gmail.com
32
yum DVD
yum rpm A
B C yum rpm
yum yum
yum DVD
1) /etc/yum.repos.d/
2) CentOS-Base.repo #
3) CentOS-Media.repo DVD
baseurl=file:///media/CentOS_6.0_Final/
4) enabled=0 enabled=1
yum DVD
rpm
yum
:
http://www.thaiadmin.org/board/index.php?topic=41613.0
http://en.wikipedia.org/wiki/Yellow_dog_Updater,_Modified
CentOS 6 sothorn@gmail.com
33
CentOS
.
http://mirror1.ku.ac.th/yum-centos/6/CentOS-Base.repo CentOSBase.repo
#cpCentOSBase.repo/etc/yum.repos.d/
RPMForge
http://wiki.centos.org/AdditionalResources/Repositories/RPMForge
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
CentOS 6 sothorn@gmail.com
34
35
BIND CentOS
#yuminstallbind
/etc/named.conf
/var/named /etc/named.conf
1.
2. /etc/name.conf
3. IP Address /var/named
4. IP Address /var/named
5. start restart service named
6. /etc/resolv.conf network
7.
IP 192.168.01 companyname.com
http://www.companyname.com
CentOS 6 sothorn@gmail.com
36
/etc/named.conf
CentOS 5.2 named.conf
zone"companyname.com.zone"IN{
typemaster;
file"/var/named/companyname.com.zone";
allowupdate{none;};
};
zone"0.168.192.inaddr.arpa"IN{
typemaster;
file"/var/named/0.168.192.rev";
allowupdate{none;};
};
/etc/named.conf
/etc/named.conf
named-checkconf /etc/named.conf
#namedcheckconf/etc/named.conf
/etc/named.conf:11:'mastor'unexpected
#namedcheckconf/etc/named.conf
#
IP Address
companyname.com.zone IP Address
/var/named
$TTL86400
@INSOAcompanyname.com.
root.companyname.com.(
100;serial
1H;refresh
1M;retry
1W;expiry
1D);minimum
@INNSns1.companyname.com.
@INA192.168.0.1
ns1INA192.168.0.1
@INMX10mail.companyname.com.
mailINA192.168.0.1
wwwINA192.168.0.1
CentOS 6 sothorn@gmail.com
37
IP Address (0.168.192.rev)
0.168.192.rev IP Address
/var/named
$TTL86400
@INSOAcompanyname.com.root.companyname.com.
(
100;serial
1H;refresh
1M;retry
1W;expiry
1D);minimum
@INNSns1.companyname.com.
1INPTRwww.companyname.com.
named
named # /etc/init.d/named restart service named restart
DNS Client
DNS Client
DNS Client /etc/resolv.conf nameserver 192.168.0.1
# /etc/init.d/network restart
dig,
nslookup host
CentOS 6 sothorn@gmail.com
38
#digcompanyname.com
;<<>>DiG9.7.0P2RedHat9.7.05.P2.el6<<>>companyname.com
;;globaloptions:+cmd
;;Gotanswer:
;;>>HEADER<<opcode:QUERY,status:NOERROR,id:50172
;;flags:qraardra;QUERY:1,ANSWER:1,AUTHORITY:1,ADDITIONAL:1
;;QUESTIONSECTION:
;companyname.com.
IN
;;ANSWERSECTION:
companyname.com.86400 IN
192.168.0.1
;;AUTHORITYSECTION:
companyname.com.86400 IN
NS
ns1.companyname.com.
;;ADDITIONALSECTION:
ns1.companyname.com. 86400 IN
192.168.0.1
;;Querytime:4msec
;;SERVER:192.168.0.1#53(192.168.0.1)
;;WHEN:TueFeb2815:48:402012
;;MSGSIZErcvd:83
#nslookupcompanyname.com
Server:
192.168.0.1
Address:
192.168.0.1#53
Name: companyname.com
Address:192.168.0.1
#
#hostwww.companyname.com
www.companyname.comhasaddress192.168.0.1
CentOS 6 sothorn@gmail.com
39
TTL
@
IN
Serial
Refresh
Retry
Expire
SOA
NS
A
CNAME
MX
PTR
(Time to Live)
companyname.com /etc/named.conf
Primary Master Secondary Master
Primary Master Secondary Master DNS
Primary Secondary
Primary
(refresh) Primary
Start of authority
Name Server record SOA
Address record IP Address
Canonical name (Alias name)
Mail server exchange
Pointer Record IP Address
DNS
CentOS 6 sothorn@gmail.com
40
4 MySQL
MySQL () SQL. MySQL
MySQL AB
MySQL MySQL 2
David Axmark, Allan Larsson Michael "Monty" Widenius.
(Sun Microsystems, Inc.) MySQL AB
MySQL AB
: http://th.wikipedia.org/wiki/MySQL
MySQL CentOS
CentOS MySQL
gpk-application # gpk-application System -->Administration--> Add /
Remove Software
MySQL gpk-application
CentOS 6 sothorn@gmail.com
41
MySQL
MySQL MySQL
mysql.com MySQL http://www.percona.com/
http://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.20-24.1/RPM/rhel6/x86_64/
CPU CPU
1) mysqldump
2) MySQL /etc/init.d/mysqld stop
3) MySQL CentOS 6 yum remove mysql-server
4) http://www.percona.com/downloads/Percona-Server-5.5/Percona-Server5.5.20-24.1/RPM/rhel6/x86_64/
Percona
4 Apache+PHP
#ls
PerconaServerclient555.5.20rel24.1.217.rhel6.x86_64.rpm
PerconaServershared555.5.20rel24.1.217.rhel6.x86_64.rpm
PerconaServerserver555.5.20rel24.1.217.rhel6.x86_64.rpm
PerconaServersharedcompat5.5.20rel24.1.217.rhel6.x86_64.rpm
CentOS 6 sothorn@gmail.com
42
MySQL
#mysql
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis4
Serverversion:5.5.2055PerconaServer(GPL),Releaserel24.1,
Revision217
Copyright(c)2000,2011,Oracleand/oritsaffiliates.Allrights
reserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinput
statement.
mysql>
[OK]
CentOS 6 sothorn@gmail.com
43
user root
user root
user mysqladmin -u root password mypassword mypassword
user root mypassword
#mysqladminurootpasswordmypassword
#mysqlurootp
Enterpassword:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis3
Serverversion:5.5.2055PerconaServer(GPL),Releaserel24.1,
Revision217
Copyright(c)2000,2011,Oracleand/oritsaffiliates.Allrights
reserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinput
statement.
mysql>
MySQL
mysql>\q
Bye
#
mysql>exit
Bye
#
CentOS 6 sothorn@gmail.com
44
#mysqlurootp
Enterpassword:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis6
Serverversion:5.5.2055PerconaServer(GPL),Releaserel24.1,
Revision217
Copyright(c)2000,2011,Oracleand/oritsaffiliates.Allrights
reserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinput
statement.
mysql>
2 -p
#mysqlurootpmypassword
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis6
Serverversion:5.5.2055PerconaServer(GPL),Releaserel24.1,
Revision217
Copyright(c)2000,2011,Oracleand/oritsaffiliates.Allrights
reserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinput
statement.
mysql>
#mysqlurootp
Enterpassword:
ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(using
password:YES)
#
MySQL
CentOS 6 sothorn@gmail.com
45
#mysqladmincreatnewdburootp
Enterpassword:
#mysqlurootp
Enterpassword:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis12
Serverversion:5.0.45Sourcedistribution
Type'help;'or'\h'forhelp.Type'\c'toclearthebuffer.
mysql>showdatabases;
++
|Database|
++
|information_schema|
|mysql|
|newdb|
|test|
++
4rowsinset(0.00sec)
mysql>
backup
mysql newdb < /path/to/file.sql -u root -p
#mysqlnewdb</root/file.sqlurootp
Enterpassword:
Backup dump
#mysqldumpdbname>/root/file_backup.sqlurootp
Enterpassword:
CentOS 6 sothorn@gmail.com
46
#mysqlurootp
Enterpassword:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis6
Serverversion:5.5.2055PerconaServer(GPL),Releaserel24.1,
Revision217
Copyright(c)2000,2011,Oracleand/oritsaffiliates.Allrights
reserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinput
statement.
mysql>
mysql>usemysql;
Readingtableinformationforcompletionoftableandcolumnnames
YoucanturnoffthisfeaturetogetaquickerstartupwithA
Databasechanged
mysql>UPDATEmysql.userSETPassword=PASSWORD('newpassword')WHERE
User='root';
QueryOK,0rowsaffected(0.00sec)
Rowsmatched:3Changed:0Warnings:0
mysql>flushprivileges;
QueryOK,0rowsaffected(0.00sec)
mysql>
mysql>SETPASSWORDFOR'root'@'localhost'=PASSWORD('newpassword);
newpassword
where user
user
MySQL user root
user user
mysql>GRANTALLPRIVILEGESON*.*TOnew_user@"%"IDENTIFIEDBY
'password_for_newuser'WITHGRANTOPTION;
mysql>FLUSHPRIVILEGES;
mysql>flushprivileges;
QueryOK,0rowsaffected(0.00sec)
CentOS 6 sothorn@gmail.com
47
user sothorn
(%) (*.*) db.* mydb.*
root@amdx2:~#mysqlh192.168.0.1usothornp
Enterpassword:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis6
Serverversion:5.5.2055PerconaServer(GPL),Releaserel24.1,
Revision217
Copyright(c)2000,2011,Oracleand/oritsaffiliates.Allrights
reserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinput
statement.
mysql>
root MySQL
user root MySQL
#/etc/init.d/mysqldstop
#/usr/bin/mysqld_safeuser=rootskipgranttables&
#mysql
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis2
Serverversion:5.0.45Sourcedistribution
Type'help;'or'\h'forhelp.Type'\c'toclearthebuffer.
mysql>UPDATEmysql.userSETPassword=PASSWORD('newpassword)WHERE
User='root';
mysql>FLUSHPRIVILEGES;
mysq>\q
#mysqladminshutdown
#/etc/init.d/mysqldstart
MySQL MySQL
skipgranttables MySQL
update
CentOS 6 sothorn@gmail.com
48
5 Apache+PHP phpMyAdmin
html
PHP MySQL,
PostgreSQL
CentOS Apache2
httpd
Web Server+PHP
Apache PHP # gpk-application System -->Administration-->
Add / Remove Software
Web Server
gpk-application
CentOS 6 sothorn@gmail.com
49
PHP Support
PHP gpk-application
PHP
Close Apply
#chkconfighttpdon
httpd
httpd
#servicehttpdstart
#/etc/init.d/httpdstart
CentOS 6 sothorn@gmail.com
50
Default http://www.companyname.com
PHP
phpinfo.php
<?php
phpinfo();
?>
PHP
CentOS 6 sothorn@gmail.com
51
PHP MySQL
connect.php /var/www/html
<?php
$link=mysql_connect('localhost','root','mypassword');
if(!$link){
die('Couldnotconnect:'.mysql_error());
}
echo'Connectedsuccessfully';
mysql_close($link);
?>
Browser
Browser URL http://www.companyname.com/connect.php
PHP MySQL
CentOS 6 sothorn@gmail.com
52
6 phpMyAdmin
phpMyAdmin PHP MySQL
Web Browser http://www.phpmyqdmin.net
phpMyAdmin php-mbstring
#yuminstallphpmbstring
#servicehttpdrestart
#tarxvfzphpMyAdmin3.4.10.1alllanguages.tar.gz
phpMyAdmin3.4.10.1alllanguages/
phpMyAdmin3.4.10.1alllanguages/db_tracking.php
phpMyAdmin3.4.10.1alllanguages/schema_edit.php
phpMyAdmin3.4.10.1alllanguages/server_databases.php
#mvphpMyAdmin3.4.10.1alllanguages/var/www/html/phpMyAdmin
/var/www/html/phpMyAdmin
#cd/var/www/html/phpMyAdmin
#cpconfig.sample.inc.phpconfig.inc.php
config.inc.php
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'http';
CentOS 6 sothorn@gmail.com
53
http://www.companyname.com/phpMyAdmin
phpMyAdmin
CentOS 6 sothorn@gmail.com
54
inet_interfaces = localhost
mail mail mail server
inet_interfaces = all
home_mailbox = Maildir/ # roundcubemail
CentOS 6 sothorn@gmail.com
55
mail server
CentOS 6 sothorn@gmail.com
56
8 roundcubemail
roundcubemail PHP http://roundcube.net/
roundcubemail IMAP roundcube
IMAP mail dovecot
1) dovecot
#yuminstalldovecot
#chkconfigdovecoton
#servicedovecotstart#/etc/init.d/dovecotstart
dovecot /etc/dovecot/dovecot.conf
protocols = imap pop3
mail_location = maildir:~/Maildir
#servicedovecotrestart
roundcube roundcube
#yuminstallphpmbstring
#yuminstallphpmcrypt
#yuminstallphpintl
#servicehttpdrestart
#tarxvfzroundcubemail0.7.2.tar.gz
roundcubemail0.7.2/
roundcubemail0.7.2/.htaccess
roundcubemail0.7.2/bin/
...
#mvroundcubemail0.7.2/var/www/html/roundcubemail
roundcubemail
/var/www/html/roundcubemail
#cd/var/www/html/roundcubemail
CentOS 6 sothorn@gmail.com
57
roundcubemail
#mysql
>CREATEDATABASEroundcubemail/*!40101CHARACTERSETutf8COLLATE
utf8_general_ci*/;
>GRANTALLPRIVILEGESONroundcubemail.*TOroundcube@localhost
IDENTIFIEDBY'123456';
>quit
#mysqlroundcubemail<SQL/mysql.initial.sql
CentOS 6 sothorn@gmail.com
58
START INSTALLATION
CentOS 6 sothorn@gmail.com
59
IMAP host
CentOS 6 sothorn@gmail.com
60
SMTP Setting
th_TH
CentOS 6 sothorn@gmail.com
61
CREATE CONFIG
main.inc.php /var/www/html/roundcubemail/config
CentOS 6 sothorn@gmail.com
62
db.inc.php /var/www/html/roundcubemail/config
http://www.companyname.com/roundcubemail
Login user
CentOS 6 sothorn@gmail.com
63
Login
CentOS 6 sothorn@gmail.com