設定 Linux CentOS
  • 7,869 views,
  • 2013-09-19,
  • 上傳者: Kuann Hung,
  •  0
23e484af1816561bb952cb673938bfb4.jpg
 
這篇只介紹如何設定 LAMP (Linux + Apache + MySQL + PHP) 。
 
系統的設定部分請參考 設定 Linux CentOS (系統部分)
記錄一下我自己的步驟。
 
 
步驟
1.
Update all packages
# yum -y update
2.
Install Webmin
請自行尋找最新版下載 (http://webmin.com/download.html)
# wget http://downloads.sourceforge.net/project/webadmin/webmin/1.520/webmin-1.520.tar.gz
# tar -zxvf webmin-1.520.tar.gz
# cd webmin-1.520
webmin-1.520]# ./setup.sh
  
***********************************************************************
*           Welcome to the Webmin setup script, version 1.520       *
***********************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.
  
Installing Webmin in /root/webmin-1.520 ...
  
***********************************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults.
  
Config file directory [/etc/webmin]:
Log file directory [/var/webmin]:
  
***********************************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system.
  
Full path to perl (default /usr/bin/perl):
  
Testing Perl ...
Perl seems to be installed ok
  
***********************************************************************
Operating system name:  CentOS Linux
Operating system version: 5.5
  
***********************************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :
 - What port to run the web server on. There must not be another
   web server already using this port.
 - The login name required to access the web server.
 - The password required to access the web server.
 - If the webserver should use SSL (if your system supports it).
 - Whether to start webmin at boot time.
  
Web server port (default 10000):
Login name (default admin):
Login password:
Password again:
The Perl SSLeay library is not installed. SSL not available.
Start Webmin at boot time (y/n): Y
  
***********************************************************************
Creating web server config files..
..done
  
Creating access control file..
..done
  
Inserting path to perl into scripts..
..done
  
Creating start and stop scripts..
..done
  
Copying config files..
..done
  
Creating uninstall script /etc/webmin/uninstall.sh ..
..done
  
Changing ownership and permissions ..
..done
  
Running postinstall scripts ..
..done
  
Enabling background status collection ..
..done
  
Attempting to start Webmin mini web server..
Starting Webmin server in /root/webmin-1.520
Pre-loaded WebminCore
..done
  
***********************************************************************
Webmin has been installed and started successfully. Use your web
browser to go to
  
  http://yourserver.com:10000/
 
and login with the name and password you entered previously.
3.
Setup SSL for Webmin
 
進入 Webmin 的管理介面後,操作如下
[Webmin] -> [Webmin configuration] -> [SSL Encryption]
    set Enable SSL if available? Yes
          Redirect non-SSL requests to SSL mode? Yes
4.
Install Apache
# yum -y install httpd mod_ssl GeoIP*
5.
Install MySQL
[mysqld]
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
user=mysql
old_passwords=1
set-variable = table_cache=512
set-variable = key_buffer=256M
set-variable = sort_buffer=8M
set-variable = myisam_sort_buffer_size=256M
set-variable = max_allowed_packet=1M
set-variable = net_buffer_length=4M
set-variable = max_heap_table_size=256M
set-variable = join_buffer_size=8M
set-variable = read_buffer_size=16M
set-variable = read_rnd_buffer_size=8M
set-variable = sort_buffer_size=4M
set-variable = bulk_insert_buffer_size=8M
set-variable = query_cache_type=1
set-variable = query_cache_size=256M
 
big-tables
skip-locking
innodb_file_per_table = 1
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
6.
Install PHP
 
yum -y install php php-*
7.
Install RPMForge / memcache / gcc / ntp

以下是 For 64 位元的,如果是 32 的要自己換一下檔名,然後找最新版即可!

# rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm # yum -y install libevent memcached gcc c++ ntp
# yum -y install libevent memcached gcc c++ ntp
  
# vi /etc/sysconfig/clock 
UTC=true
ARC=false
ZONE=Asia/Taipei
8.
Setup Linux Firewall (in Webmin)
Action       Condition      
Accept     If input interface is not eth0        
Accept     If protocol is TCP and TCP flags ACK (of ACK) are set        
Accept     If state of connection is ESTABLISHED         
Accept     If state of connection is RELATED         
Accept     If protocol is UDP and destination port is 1024:65535 and source port is 53       
Accept     If protocol is ICMP and ICMP type is echo-reply       
Accept     If protocol is ICMP and ICMP type is destination-unreachable      
Accept     If protocol is ICMP and ICMP type is source-quench        
Accept     If protocol is ICMP and ICMP type is time-exceeded        
Accept     If protocol is ICMP and ICMP type is parameter-problem        
Accept     If protocol is ICMP and ICMP type is echo-request         
Accept     If protocol is TCP and destination port is 22         
Accept     If protocol is TCP and destination port is 80         
Accept     If protocol is TCP and destination port is 10000
9.
Setup phpMyAdmin

一樣要自己查新版的檔名喔!
# wget  http://superb-sea2.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.7/phpMyAdmin-3.3.7-all-languages.tar.gz
# tar -zxvf phpMyAdmin-3.3.7-all-languages.tar.gz
# mv phpMyAdmin-3.3.7-all-languages /var/www/luke54_myadmin
view source
print?
# vi /etc/httpd/conf.d/myadmin.conf
 
<Location /phpMyAdmin>
    Order deny,allow
    allow from all
</Location>
10.
Upgrade PHP to v5.2
 
# vi /etc/yum.repos.d/CentOS-Base.repo
[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/5/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
11.
設定 Apache (virtual domain)
 
# vi /etc/httpd/conf/httpd.conf
設定 gzip 以及 expired header
 
<IfModule mod_deflate.c>
    # compress content with type html, text, and css
    AddOutputFilterByType DEFLATE text/html text/plain text/css
    AddOutputFilter DEFLATE js css html ico
    <IfModule mod_headers.c>
    # properly handle requests coming from behind proxies
    Header append Vary User-Agent
     </IfModule>
</IfModule>
<IfModule mod_expires.c>
   ExpiresActive on
   ExpiresByType image/jpg "access plus 7 days"
   ExpiresByType image/jpeg "access plus 7 days"
   ExpiresByType image/gif "access plus 7 days"
   ExpiresByType image/png "access plus 7 days"
   ExpiresByType application/x-javascript "access plus 7 days"
   ExpiresByType application/x-shockwave-flash "access plus 1 month"
   ExpiresByType text/html "access plus 1 day"
   ExpiresByType text/css "access plus 7 days"
   ExpiresDefault "access 2 days"
</IfModule>
 
AllowOverride All
 
<VirtualHost *:80>
    ServerAdmin root@example.com
    DocumentRoot /var/www/example
    ServerName www.example.com
    ErrorLog logs/www.example.com-error.log
    CustomLog logs/www.example.com-access.log common
</VirtualHost>
12.
設定 Samba
 
# vi /etc/samba/smb.conf
; 請自行查出相對應的位置加上或修改參數
 
[global]
display charset = UTF8
dos charset = UTF8
unix charset = UTF8
guest account = apache
 
security = share
 
[www]
comment = Web Directory
path = /var/www
public = yes
writable = yes
browseable = yes
printable = no
guest ok = yes
write list = +staff
create mode    = 0777
directory mode = 0777
 
create mask = 0777
force create mode = 0777
security mask = 0777
force security mode = 0777
 
directory mask = 0777
force directory mode = 0777
directory security mask = 0777
force directory security mode = 0777
 
acl check permissions = False
Facebook 討論區載入中...
資料夾 :
發表時間 :
2013-09-19 04:08:17
觀看數 :
7,869
發表人 :
Kuann Hung
部門 :
老洪的 IT 學習系統
QR Code :