Pythontr

husonet | Tarih: 15.04.2011

apache,php,mysql,shorewall kurulumu ve konfigurasyonu

apache,php,mysql,shorewall kurulumu, konfigurasyon işlemleri sizler için yapılandırdık

root olalım
su -

güncellemeler varsa yapalım


aptitude update && aptitude full-upgrade 

gereksiz gördüğüm paketleri kaldıralım


aptitude purge installation-report tasksel tasksel-data nano laptop-detect gcc-4.2-base man-db manpages manpages-tr info


gerekli gördüğüm paketler
aptitude install screen vim sysv-rc-conf dash pciutils ipython python-mysqldb mysql-server ntpdate apache2 libapache2-mod-python libapache2-mod-php5 php5-mysql php5-curl php5-gd php5-cli curl ncftp shorewall rsyslog-mysql freeradius-mysql php5-radius sudo 


bash'den dash'a geçiş yapmak istersek
dpkg-reconfigure dash # (yes)


heryerden mysql connection una izin vermek istersek
vim /etc/mysql/my.cnf
bind-address = 0.0.0.0


firewall ayarlarını yapalım, 169.10.112.200 ip'iye uzaktan mysql (3306 portuna) e bağlanma izni verelim.
vim /etc/shorewall/rules
#fw
ACCEPT fw net icmp
# net
ACCEPT net:169.10.112.200 fw tcp 3306
ACCEPT net fw tcp 514
ACCEPT net fw udp 514
ACCEPT net fw udp 1812
ACCEPT net fw udp 1813
ACCEPT net fw udp 1814
ACCEPT net fw tcp 11122
HTTP/ACCEPT net fw
Ping/ACCEPT net fw


Apache ayarlarını yapalım.

- Kurulum
# PHP ile kullanilacaksa
aptitude install apache2-mpm-prefork libapache2-mod-php5

# Thread sorunu olmayan bir dil ile kullanılacaksa
aptitude install apache2-mpm-worker


- Ayarlar
# Ayarların doğruluğunun testi
restart veya reload yapmadan önce ayarların doğruluğu test edilsin.
apachectl configtest
/etc/init.d/apache2 reload

# Yoğun sunucularda apache2-mpm-prefork için

curl site.com | grep "src=" | wc -l ile bir bağlantıda yaklaşık
kaç adet istek olabileceğini tahmin et. Buna göre MaxKeepAliveRequests
değerini belirle.

ps aux | grep apache2 ile RSS satırına bakıp her bağlantı için fiziksel
hafızadan yaklaşık kaç KB kullanıldığını kontrol et.
[Apacheye_ayrilan_RAM] / [RSS_degeri] 
formülü ile MaxClients değerinin
kaç olabileceğini tahmin et.

MaxClients 256'dan büyük olacaksa ServerLimit değerini ona eşitle.


vim	/etc/apache2/apache2.conf
Timeout 45
KeepAlive On
MaxKeepAliveRequests 256

<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 10
MaxSpareServers 100
ServerLimit 512
MaxClients 512
MaxRequestsPerChild 500
</IfModule>


Apache İstenmeyen Logları Loglama ("Apache (internal dummy connection)")
	# Filters
SetEnvIf Remote_Addr "::*" dontlog
CustomLog /var/log/apache2/access.log combined env=!dontlog


vim	/etc/security/limits.conf
www-data hard nofile 65536
www-data soft nofile 65536



# Güvenlik
vim	/etc/apache2/conf.d/security
ServerTokens Prod
ServerSignature Off
TraceEnable Off



# Dosya tipine göre cache süreleri
	cd /etc/apache2/mods-enabled
ln -s ../mods-available/expires.load .


vim	/etc/apache2/sites-enables/ilgili_dosya
<Directory ...>
...

<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 4 hours"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/jpg "access plus 30 days"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/bmp "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType text/html "access plus 30 seconds"
ExpiresByType text/xml "access plus 45 seconds"
ExpiresByType text/plain "access plus 60 seconds"
ExpiresByType text/javascript "modification plus 30 days"
ExpiresByType application/javascript "access plus 30 days"
ExpiresByType application/x-javascript "access plus 30 days"
ExpiresByType application/x-shockwave-flash "access plus 30 days"
</IfModule>
</Directory>


Expire zamanını ve sayfanın header bilgilerini görmek için:
	curl --head http://www.emrah.com/resim.jpg



- ApacheTop
	aptitude install apachetop libgamin0


Diğer Ayarlar

# www dizini çalışma yolunu dğiştirelim
mkdir -p /home/www
rm -rf /var/www
vim /etc/apache2/sites-available/default
DocumentRoot /home/www/
<Directory /home/www/>
Options -Indexes FollowSymLinks MultiViews #(Indexes - oldu)

# husonet.hsn dosyasını indirme izni verelim.
vim /etc/apache2/mods-enabled/mime.conf
AddType application/husonet.hsn

/etc/init.d/apache2 restart


indirdiğimiz paketleri kaldıralım
aptitude clean


İlgili Konular
SSH Kurulumu