MySQL, Apache ve phpMyAdmin Kurulumu
1 |
yum -y install ntp httpd mysql mysql-server mysql-libs mysql-devel php php-mysql php-mbstring rpm-build gcc gcc-c++ openssl-devel cyrus-sasl-devel pkgconfig zlib-devel phpMyAdmin pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel libidn-devel db4-devel mod_ssl telnet sqlite-devel tcl tcl-devel |
komutuyla ilgili paketleri kuruyoruz.
1 |
chkconfig --levels 235 mysqld on |
komutuyla mysql sunucusunu sistem başlangıcında otomatik çalıştırılmasını sağlıyoruz.
Daha sonra mysql sunucusunu başlatıp root şifresini ayarlayacağız.
1 2 |
/etc/init.d/mysqld start mysql_secure_installation |
Konfigürasyon bilinoyorsa sorulara verilecek cevaplar değişebilir, ancak standart ve güvenli kurulum aşağıdaki gibi olmalıdır (mysqlrootşifreniz yerine kendi mysql root şifremizi yazmalıyız):
Set root password? [Y/n] <-- ENTER
New password: <-- mysqlrootşifreniz
Re-enter new password: <-- mysqlrootşifreniz
Remove anonymous users? [Y/n] <-- ENTER
Disallow root login remotely? [Y/n] <-- ENTER
Remove test database and access to it? [Y/n] <-- ENTER
Reload privilege tables now? [Y/n] <-- ENTER
1 2 3 |
mkdir -p /old/etc/ cp /etc/my.cnf /old/etc/ nano /etc/my.cnf |
komutlarıyla /etc/my.cnf dosyasını yedekleyip, düzenleme için açıyoruz:
[...]
[client]
default-character-set=utf8
[...]
[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
#bind-address = 127.0.0.1
[...][mysql]
default-character-set=utf8
1 2 |
/etc/init.d/mysqld restart netstat -tap | grep mysqld |
komutlarıyla mysql sunucusunu tekrar başlatıp, mysqld'nin neleri dinlediğini kontrol ediyoruz ve şuna benzer bir çıktı almalıyız:
tcp 0 0 *:mysql *:* LISTEN 1661/mysqld
1 2 3 |
mkdir -p /old/etc/httpd/conf.d/ cp /etc/httpd/conf.d/phpMyAdmin.conf /old/etc/httpd/conf.d/ pico /etc/httpd/conf.d/phpMyAdmin.conf |
komutlarıyla /etc/httpd/conf.d/phpMyAdmin.conf dosyasını yedekledik, picoyla açtık;
[...]
#<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>
[...]
açıklamadaki gibi kırmızı-kalın diyezleri ilgili satırların başına ekliyoruz.
1 2 3 |
mkdir -p /old/etc/phpMyAdmin/ cp /etc/phpMyAdmin/config.inc.php /old/etc/phpMyAdmin/ pico /etc/phpMyAdmin/config.inc.php |
komutlarıyla /etc/phpMyAdmin/config.inc.php dosyasını yedekledik picoyla açtık;
[...]
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'W7F58R'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
[...]
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)?
[...]
$cfg['SaveDir'] = '/var/lib/phpMyAdmin/save';
//$cfg['ThemeDefault'] = 'pmahomme';
$cfg['ThemeDefault'] = 'original';
$cfg['VersionCheck'] = FALSE;
[...]
açıklamalardaki gibi kırmızı-kalın kısımları ilgili yerlere ekliyoruz.
1 2 |
chkconfig --levels 235 httpd on service httpd start |
httpd (apache) sunucusunu sistem başlangıcında otomatik çalışacak şekilde ayarladık ve servisi başlattık. Yeniden başlatmak için;
1 |
service httpd restart |
UserDir Özelliği (/home/*/public_html/)
httpd'nin varsayılan kök dizini /var/www/html dizinidir. /home dizini altında herhangi bir kullanıcının web dosyalarını görüntülemek için standart olarak bir public_html dizini oluşturulur ve html, php, asp vb web dosyaları bu dizine atılır. www.alanadi.com/~user1/index.html gibi bir adresi çalıştırmak için aşağıdaki ayarlamaları yapacağız;
1 2 3 |
mkdir -p /old/etc/httpd/conf/ cp /etc/httpd/conf/httpd.conf /old/etc/httpd/conf/ nano /etc/httpd/conf/httpd.conf |
komutlarıyla /etc/httpd/conf/httpd.conf dosyasını yedekledik, nanoyla açtık;
[...]
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disabled
UserDir "enabled *"
UserDir "disabled root"#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html</IfModule>
[...]
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
[...]
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.php index.php3 index.cgi index.pl index.html index.htm index.shtml index.xhtml
[...]
Açıklamada yeralan kırmızı-kalın kısımlar gibi ilgili yerlerde değişiklik yapıyoruz.
(DİKKAT! Aşağıdaki komutlarda user1 yazan yerlere kendi kullanacağımız kullanıcı adımızı yazıyoruz.)
1 2 3 4 5 6 |
mkdir -p /home/user1/public_html/ chmod 711 /home chmod 711 /home/user1 chmod 775 /home/user1/public_html chown user1:apache /home/user1>/public_html service httpd restart |
komutlarıyla da user1 kullanıcısı için public_html klasörü oluşturup ilgili dizinlere okuma-yazma izinlerini verip servisi yeniden başlatıyoruz.
Apache2'nin mod_php, mod_fcgi/PHP5 ve suPHP ile Kurulması
1 |
yum -y install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel mod_fcgid php-cli httpd-devel |
komutuyla başlıktaki ayarlamalar için gerekli olan paketleri kuruyoruz.
1 2 3 |
mkdir -p /old/etc/ cp /etc/php.ini /old/etc/ pico /etc/php.ini |
komutlarıyla /etc/php.ini dosyasını yedekledik, picoyla açtık;
[...]
;zlib.output_compression = Off
zlib.output_compression = On
[...]
;error_reporting = E_ALL & ~E_DEPRECATED
error_reporting = E_ALL & ~E_NOTICE
[...]
;post_max_size = 8M
post_max_size = 20M
[...]
;default_charset = "iso-8859-1"
default_charset = "utf-8"
[...]
;cgi.fix_pathinfo=1
cgi.fix_pathinfo=1
[...]
; http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
;upload_max_filesize = 2M
upload_max_filesize = 20M
[...]
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
date.timezone = Europe/Istanbul
1 2 3 4 5 6 7 8 9 10 11 |
cd /tmp wget http://suphp.org/download/suphp-0.7.1.tar.gz tar xvfz suphp-0.7.1.tar.gz cd suphp-0.7.1/ ./configure --prefix=/usr --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-apxs=/usr/sbin/apxs --with-apache-user=apache --with-setid-mode=owner --with-php=/usr/bin/php-cgi --with-logfile=/var/log/httpd/suphp_log --enable-SUPHP_USE_USERGROUP=yes make make install cd /tmp mkdir -p /root/.sources/ mv *.tar.gz /root/.sources/ pico /etc/httpd/conf.d/suphp.conf |
komutlarıyla suphp kaynak kodlarını indirip derliyoruz. /etc/httpd/conf.d/suphp.conf dosyasını pico ile açıyoruz;
LoadModule suphp_module modules/mod_suphp.so
ibaresini ekleyip kaydedip kapatıyoruz.
1 |
pico /etc/suphp.conf |
ile /etc/suphp.conf dosyasını açıyoruz;
[global]
;Path to logfile
logfile=/var/log/httpd/suphp.log;Loglevel
loglevel=info;User Apache is running as
webserver_user=apache;Path all scripts have to be in
docroot=/;Path to chroot() to before executing script
;chroot=/mychroot
; Security options
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
allow_directory_others_writeable=false;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true;Send minor error messages to browser
errors_to_browser=false;PATH environment variable
env_path=/bin:/usr/bin;Umask to set, specify in octal notation
umask=0077; Minimum UID
min_uid=100; Minimum GID
min_gid=100[handlers]
;Handler for php-scripts
x-httpd-suphp="php:/usr/bin/php-cgi";Handler for CGI-scripts
x-suphp-cgi="execute:!self"
açıklamada yer alan ibareleri ekliyoruz (tümünü).
1 2 3 4 |
echo '<html><head><style type="text/css">h1 {color:orange; text-align:center;} p {color:green; text-align:center;}</style><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>(/var/www/html/)</title></head><body><h1>Çalışıyor!</h1><p>Bu sunucunuzun varsayılan sayfasıdır.</p><p>Web sunucu yazılımı çalışıyor, fakat henüz içerik eklenmemiş.</p></body></html>' > /var/www/html/index.html chown root:apache /var/www/html && chmod 775 /var/www/html cd /var/www/html find . -type f -exec chown root:apache {} \; && find . -type d -exec chown root:apache {} \; && find . -type f -exec chmod 664 {} \; && find . -type d -exec chmod 775 {} \; |
komutlarıyla /var/www/html dizinine index.html dosyası ekleyip ilgili okuma-yazma izinlerini ayarlıyoruz.
(DİKKAT! Aşağıdaki komutlarda user1 yazan yerlere kendi kullanacağımız kullanıcı adımızı yazıyoruz ve bu kullanıcının sudo yetkisi olmalıdır)
1 2 3 4 5 6 |
su user1 cd ~ && mkdir -p ~/public_html && echo '<html><head><style type="text/css">h1 {color:red; text-align:center;} p {color:blue; text-align:center;}</style><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>(user1~/public_html/)</title></head><body><h1>Çalışıyor!</h1><p>Bu sunucunuzun varsayılan sayfasıdır.</p><p>Web sunucu yazılımı çalışıyor, fakat henüz içerik eklenmemiş.</p></body></html>' > ~/public_html/index.html sudo chown user1:apache ~/public_html && chmod 775 ~/public_html cd ~/public_html sudo find . -type f -exec chown user1:apache {} \; && sudo find . -type d -exec chown user1:apache {} \; && sudo find . -type f -exec chmod 664 {} \; && sudo find . -type d -exec chmod 775 {} \; exit |
komutlarıyla user1 olarak giriş yapıp /home/user1/public_html dizinine index.html dosyası ekleyip ilgili okuma-yazma izinlerini ayarlıyoruz ve user1'den çıkış yapıyoruz.
1 2 |
echo '<?php phpinfo(); ?>' > /var/www/html/info.php chown root:apache /var/www/html/info.php && chmod 664 /var/www/html/info.php |
/var/www/html dizinine info.php isimli bir dosya oluşturuyoruz.
1 2 3 4 |
su user1 cd ~ && echo '<?php phpinfo(); ?>' > ~/public_html/info.php sudo chown user1:apache ~/public_html/info.php && chmod 664 ~/public_html/info.php exit |
/home/user1/public_html dizinine info.php isimli bir dosya oluşturuyoruz.
1 |
pico /etc/httpd/conf.d/welcome.conf |
/etc/httpd/conf.d/welcome.conf dosyasını açıyoruz;
#
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL. To disable the Welcome page, comment
# out all the lines below.
#
#<LocationMatch "^/+$">
# Options -Indexes
# ErrorDocument 403 /error/noindex.html
#</LocationMatch>
ilgili satırların başına kırmızı-kalın yerlerdeki gibi # (diyez) ekliyoruz ki, varsayılan web dizinlerinin ve alt klasörlerin altında indexlenecek dosya olmadığında 404 hata sayfasına yönlendirmesin. Bu şekilde resim veya ilgili arşiv içeriği olan web dizinlerinin altındaki dosyaları da bir liste şeklinde görebiliriz.
0 Yorumlar.