Chroot içinde {DNS, NTP, Nginx, PHP-FPM}
-
Upload
ali-erdinc-koroglu -
Category
Internet
-
view
76 -
download
5
Transcript of Chroot içinde {DNS, NTP, Nginx, PHP-FPM}
Chroot içinde Chroot içinde {DNS, NTP, Nginx, PHP-FPM}{DNS, NTP, Nginx, PHP-FPM}
Ali Erdinç KöroğluAli Erdinç Köroğlu
[email protected] - http://ae.koroglu.org - - http://twitter.com/erdinc
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Chroot Nedir ?
● Chroot sistem çağrısı “chroot()” ilk olarak Unix Version7 gelişimi sırasında (1979) duyuruldu.
● Uygulamaları veya kullanıcıları bilgisayar kaynaklarından izole etmenin bir yoludur.
● Unix benzeri işletim sistemlerinde çalışan uygulamalar (process) ve bu uygulamaların alt işlemleri (children) için mevcut root dizininin değiştirilmesini sağlayan işlemdir.
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Niçin ?
● Test ve geliştirme süreçleriÇalışan kritik sistemler üzerinde yazılımların test edilmeden uygulanmarak risk alınması yerine chroot içinde test ortamı oluşturarak yazılımların test edilmesi
● Bağımlılık kontrolüYazılımların chroot içinde geliştirilip derlenmesiyle sadece beklenen bağımlılıkların oluştuğunun doğrulanması ve böylece olası linkleme ve farklı kütüphanelerin sisteme kurulmasının önlenmesi
● UyumlulukEski yazılım veya farklı ABI'lere sahip uygulamaların aynı sistem üzerinde isim veya linkçakışmalarına uğramadan destekledikleri kütüphaneler ve verilerle chroot ortamı içinde çalışması
● KurtarmaZarar görmüş açılamayan ortamların alternatif sistemlerle (kurulum ortamı, canlı cd vb.) veri kurtarma, dosya sistemi kontrolü vb. Işlemlerin yapılması
● Yetki/erişim kontrolüProgramların chroot dizini içerisine hapsedilerek dizin dışı erişimlerinin engellenmesiyle potansiyel zaafı olan yazılımların olası güvenlik ihlallerine karşı önlem alınması
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Bind-DNS Chroot
Bind oldukça yayın kullanılan alan adı sunucularından biridir. RHEL ve CentOS dağıtımlarındachroot edilmiş hazır RPM paketi bulunmaktadır.
[root@aek ~]# yum install bind-chroot
[root@aek ~]# yum update -y
Önce kullandığınız dağıtımı güncelleyin
CentOS7'nin resmi deposundaki chroot destekli dns sunucusu kurulumu
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Bind-DNS Chroot
İşlem tamamlandığında sistemimize bind, bind-libs ve bind-chroot paketleri kurulmuş olacak.Bizi ilgilendiren dosyalar /etc, /var/named ve /var/named/chroot dizinleri içinde bulunuyor.
İlgili ayar dosyaları chroot içine
[root@aek ~]# mv /etc/named.* /var/named/chroot/etc[root@aek ~]# cp -av /var/named/named.* /var/named/chroot/var/named/
Loglar için chroot yapısı içinde dizin oluşturulmalı
[root@aek ~]# mkdir /var/named/chroot/var/log/named[root@aek ~]# chown -R named:named /var/named/chroot/var/log/named
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Bind-DNS ChrootÖrnek named.conf
options { directory "/var/named"; pid-file "/var/run/named/named.pid"; version "not currently available"; recursion no; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; zone-statistics yes;};
controls { };
logging { channel master_log { file "/var/log/named/master.log" versions 3 size 5m; severity info; print-severity yes; print-time yes; print-category yes; }; category default { master_log; };};
zone "." IN { type hint; file "named.ca";};
include "/etc/named.rfc1912.zones";include "/etc/named.root.key";
zone "koroglu.org" { type master; file "zones/koroglu.org";};
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Bind-DNS Chroot
Ayar dosyası içinde yapılan tanımlar için gerekli dizinler oluşturulmalı
[root@aek ~]# mv /etc/named.* /var/named/chroot/etc[root@aek ~]# cp -av /var/named/named.* /var/named/chroot/var/named/
Loglar için chroot yapısı içinde dizin oluşturulmalı
[root@aek ~]# mkdir /var/named/chroot/var/log/named[root@aek ~]# chown -R named:named /var/named/chroot/var/log/named
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Bind-DNS ChrootNamed.conf içinde belirtilen ayarlar için gerekli dizinler oluşturulmalı
[root@aek ~]# mkdir /var/named/chroot/var/named/data[root@aek ~]# mkdir /var/named/chroot/var/named/zones[root@aek ~]# chown -R named:named /var/named/chroot/var/named/data[root@aek ~]# chown -R named:named /var/named/chroot/var/named/zones
$TTL 86400@ IN SOA ns1.8bitplus.com. erdinc.8bitplus.com. ( 2012030701 ; serial 43200 ; refresh (12hours) 3600 ; retry (1hour) 1209600 ; expire (2week) 6200) ; TTL minimum (2hour)
IN NS ns1.8bitplus.com. IN NS ns2.8bitplus.com. IN A 78.46.226.107
www IN A 78.46.226.107ae IN A 78.46.226.107
Örnek bir alan adı ayar dosyası : /var/named/chroot/var/named/zones/koroglu.org
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Bind-DNS ChrootRHEL7 ve CentOS7 ile birlikte SysVinit yerine Systemd kullanılmaya başlandı
[root@aek ~]# systemctl start named-chroot
Servisi başlatmak için
[root@aek ~]# systemctl enable named-chroot
Boot sonrası otomatik başlaması için
[root@aek etc]# systemctl status named-chrootnamed-chroot.service - Berkeley Internet Name Domain (DNS) Loaded: loaded (/usr/lib/systemd/system/named-chroot.service; disabled) Active: active (running) since Wed 2015-03-25 23:17:45 EET; 27s ago Process: 5225 ExecStart=/usr/sbin/named -u named -t /var/named/chroot $OPTIONS (code=exited, status=0/SUCCESS) Process: 5223 ExecStartPre=/usr/sbin/named-checkconf -t /var/named/chroot -z /etc/named.conf (code=exited, status=0/SUCCESS) Main PID: 5227 (named) CGroup: /system.slice/named-chroot.service └─5227 /usr/sbin/named -u named -t /var/named/chroot
Servis sürecini görmek için
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Network Time Protocol daemon (ntpd), sistem zamanını standart zaman sunucularıylasenkron ederek ilgili ayar ve düzenlemeleri yapan bir servistir. Ancak dns servisinde olduğugibi hazır bir chroot yapısı bulunmamaktadır.
[root@aek ~]# yum install ntp
[root@aek ~]# cd /[root@aek ~]# mkdir chroot[root@aek ~]# mkdir /chroot/ntp
Temel kurulum
Chroot için dizin oluşumu
NTPD Chroot
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
mknod -m 666 /chroot/ntp/dev/null c 1 3mknod -m 666 /chroot/ntp/dev/zero c 1 5mknod -m 444 /chroot/ntp/dev/random c 1 8mkdir /chroot/ntp/etcmkdir /chroot/ntp/procmkdir /chroot/ntp/varmkdir /chroot/ntp/var/libmkdir /chroot/ntp/var/lib/ntpmv /var/lib/ntp/drift /chroot/ntp/var/lib/ntp/chown -R ntp:ntp /chroot/ntp/var/lib/ntpmkdir /chroot/ntp/var/logmkdir /chroot/ntp/var/log/ntpstatschown -R ntp:ntp /chroot/ntp/var/log/ntpstatsmv /etc/ntp.conf /chroot/ntp/etcln -s /chroot/ntp/etc/ntp.conf /etc/ntp.confcp -a /etc/localtime /chroot/ntp/etc
Chroot dizin oluşumu
NTPD Chroot
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Chroot dizin yapısı
/chroot/ntp/├── dev│ ├── null│ ├── random│ └── zero├── etc│ ├── localtime│ ├── ntp.conf│ └── resolv.conf├── proc└── var ├── lib │ └── ntp └── log ├── ntp.log └── ntpstats
NTPD Chroot
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
/chroot/ntp/etc/ntp.conf
server 0.tr.pool.ntp.orgserver ntp.ulakbim.gov.trserver 127.127.1.0fudge 127.127.1.0 stratum 10
restrict 95.0.124.102 mask 255.255.255.240 nomodify notrap#restrict 192.168.1.0 mask 255.255.255.0 nomodify notraprestrict 127.0.0.1
#interface ignore wildcard#interface listen 192.168.1.254
driftfile /var/lib/ntp/driftlogfile /var/log/ntp.loglogconfig =syncevents +peerevents +sysevents +allclock
# CVE-2013-5211disable monitor
NTPD Chroot
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
/lib/systemd/system/ntpd-chroot.service[Unit]Description=Network Time Service (Chroot)After=syslog.target ntpdate.service sntp.serviceRequires=ntpd-chroot-mount.serviceAfter=ntpd-chroot-mount.service
[Service]Type=forkingEnvironmentFile=-/etc/sysconfig/ntpdExecStart=/usr/sbin/ntpd -i /chroot/ntp -u ntp:ntp $OPTIONSPrivateTmp=true
[Install]WantedBy=multi-user.target
[Unit]Description=Mount proc environment for NTP ChrootBindsTo=ntpd-chroot.service
[Service]Type=oneshotRemainAfterExit=yesExecStart=/bin/mount --bind /proc/ /chroot/ntp/procExecStop=/bin/umount /chroot/ntp/proc
/lib/systemd/system/ntpd-chroot-mount.service
NTPD Chroot
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
[root@aek ~]# systemctl start ntpd-chroot
Servisi başlatmak için
[root@aek ~]# systemctl enable ntpd-chroot
Boot sonrası otomatik başlaması için
[root@aek etc]# systemctl status ntpd-chrootntpd-chroot.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd-chroot.service; disabled) Active: active (running) since Thu 2015-03-26 20:02:36 EET; 1min 30s ago Process: 23190 ExecStart=/usr/sbin/ntpd -i /chroot/ntp -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 23191 (ntpd) CGroup: /system.slice/ntpd-chroot.service └─23191 /usr/sbin/ntpd -i /chroot/ntp -u ntp:ntp -g
Mar 26 20:02:36 aek ntpd[23191]: proto: precision = 0.067 usecMar 26 20:02:36 aek ntpd[23191]: 0.0.0.0 c01d 0d kern kernel time sync enabledMar 26 20:02:36 aek ntpd[23191]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16Mar 26 20:02:36 aek ntpd[23191]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123Mar 26 20:02:36 aek ntpd[23191]: Listen and drop on 1 v6wildcard :: UDP 123Mar 26 20:02:36 aek ntpd[23191]: Listen normally on 2 lo 127.0.0.1 UDP 123Mar 26 20:02:36 aek ntpd[23191]: Listen normally on 3 ens32 95.0.124.102 UDP 123Mar 26 20:02:36 aek ntpd[23191]: Listen normally on 4 lo ::1 UDP 123Mar 26 20:02:36 aek ntpd[23191]: Listen normally on 5 ens32 fe80::250:56ff:feb8:6403 UDP 123Mar 26 20:02:36 aek ntpd[23191]: Listening on routing socket on fd #22 for interface updates
NTPD Chroot
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
NTPD Chroot
ntp 23191 0.0 0.1 29364 2072 ? Ss 20:02 0:00 /usr/sbin/ntpd -i /chroot/ntp -u ntp:ntp -g
ps aux
proc /chroot/ntp/proc proc rw,nosuid,nodev,noexec,relatime 0 0
/proc/mounts
[root@aek etc]# ntpstat synchronised to NTP server (193.140.100.40) at stratum 3 time correct to within 8406 ms polling server every 64 s[root@aek etc]# ntpq -p remote refid st t when poll reach delay offset jitter==============================================================*samur.ulak.net. 150.214.94.5 2 u 13 64 1 79.898 374.274 0.000 LOCAL(0) .LOCL. 10 l 76 64 2 0.000 0.000 0.000
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Nginx Chroot
Nginx büyük yükler altında dahi çok başarılı çalışan bir HTTP, ters proxy ve eposta proxySunucusudur. RHEL EPEL deposu daha düşük bir versiyon'a sahip olduğundan nginxiçin yum'a nginx resmi deposunu eklemek gerekmektedir.
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
/etc/yum.repos.d/nginx.repo
yum upgradeyum install nginx
Yum repolarını güncelleyerek nginx kurulumu
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Nginx Chroot
[root@aek ~]# cd /[root@aek ~]# mkdir /chroot/nginx[root@aek ~]# mkdir /chroot/nginx/dev[root@aek ~]# mkdir /chroot/nginx/etc[root@aek ~]# mkdir /chroot/nginx/etc/sysconfig[root@aek ~]# mkdir /chroot/nginx/proc[root@aek ~]# mkdir /chroot/nginx/run[root@aek ~]# mkdir /chroot/nginx/sbin[root@aek ~]# mkdir /chroot/nginx/srv-www[root@aek ~]# mkdir /chroot/nginx/sys[root@aek ~]# mkdir /chroot/nginx/tmp[root@aek ~]# mkdir /chroot/nginx/usr[root@aek ~]# mkdir /chroot/nginx/usr/lib64[root@aek ~]# mkdir /chroot/nginx/usr/sbin[root@aek ~]# mkdir /chroot/nginx/usr/share[root@aek ~]# mkdir /chroot/nginx/var[root@aek ~]# mkdir /chroot/nginx/var/cache[root@aek ~]# mkdir /chroot/nginx/var/cache/nginx[root@aek ~]# mkdir /chroot/nginx/var/cache/log[root@aek ~]# mkdir /chroot/nginx/var/cache/log/nginx
Gerekli dizinler
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Nginx Chroot
mknod -m 0666 /chroot/nginx/dev/null c 1 3mknod -m 0666 /chroot/nginx/dev/random c 1 8mknod -m 0444 /chroot/nginx/dev/urandom c 1 9
Gerekli aygıtlar
[root@aek etc]# grep -i nginx "/etc/passwd" > /chroot/nginx/etc/passwd[root@aek etc]# grep -i nginx "/etc/group" > /chroot/nginx/etc/group[root@aek etc]# grep -i nginx "/etc/shadow" > /chroot/nginx/etc/shadow[root@aek etc]# grep -i nginx "/etc/gshadow" > /chroot/nginx/etc/gshadow
[root@aek etc]# mv /etc/nginx /chroot/nginx/etc[root@aek etc]# ln -s /chroot/nginx/etc/nginx /etc/nginx
Nginx kullanıcısı için gerekli dosyalar
Nginx ayar dosyaları chroot içine
[root@aek etc]# cd /chroot/nginx[root@aek nginx]# ln -s usr/sbin/ sbin[root@aek nginx]# ln -s usr/lib64 lib64[root@aek nginx]# cd var/[root@aek var]# ln -s ../run/ run
Gerekli symlink'ler
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Nginx Chroot
cp $(ldd /usr/sbin/nginx | grep /lib | sed -sre 's/(.+)(\/usr\/lib\/\S+).+/\2/g') /chroot/nginx/lib64
Gerekli kütüphaneler chroot içine
[root@aek ~]# cp -a /usr/lib64/libnss_files-2.17.so /chroot/nginx/usr/lib64/[root@aek ~]# cd /chroot/nginx/usr/lib64/[root@aek lib64]# ln -s libnss_files-2.17.so libnss_files.so.2
[root@aek lib64]# chown -R nginx:root /chroot/nginx/var/cache/nginx/
Nginx kullanıcı için gerekli nss kütüphanesi
Cache dizin erişimi
[root@aek lib64]# cd /usr/share/nginx/html[root@aek html]# cp -a * /chroot/nginx/usr/share/nginx/html/
Nginx html dosyaları
setcap 'cap_net_bind_service=+ep' /chroot/nginx/usr/sbin/nginx
Root kullanıcısı haricinde 1-1023 portları arası port açma izni
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Nginx Chroot/etc/fstab
[Unit]Description=Nginx (Chroot) - high performance web serverDocumentation=http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target
[Service]Type=forkingPIDFile=/chroot/nginx/run/nginx.pidExecStartPre=/sbin/chroot --userspec=nginx:nginx /chroot/nginx /usr/sbin/nginx -t -qExecStart=/sbin/chroot --userspec=nginx:nginx /chroot/nginx /usr/sbin/nginxExecReload=/sbin/chroot --userspec=nginx:nginx /chroot/nginx /usr/sbin/nginx -s reloadExecStop=/sbin/chroot --userspec=nginx:nginx /chroot/nginx /usr/sbin/nginx -s quitPrivateTmp=true
[Install]WantedBy=multi-user.target
tmpfs /chroot/nginx/run tmpfs rw,noexec,relatime,size=1024k 0 0tmpfs /chroot/nginx/tmp tmpfs rw,noexec,relatime,size=102400k 0 0/proc /chroot/nginx/proc auto bind 0 0/sys /chroot/nginx/sys auto bind 0 0
/lib/systemd/system/nginx-chroot.service
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Nginx Chroot
[root@aek run]# systemctl status nginx-chrootnginx-chroot.service - Nginx (Chroot) - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx-chroot.service; disabled) Active: active (running) since Thu 2015-03-26 23:21:58 EET; 15min ago Docs: http://nginx.org/en/docs/ Process: 24666 ExecStop=/sbin/chroot --userspec=nginx:nginx /chroot/nginx /usr/sbin/nginx -s quit (code=exited, status=0/SUCCESS) Process: 24676 ExecStart=/sbin/chroot --userspec=nginx:nginx /chroot/nginx /usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 24675 ExecStartPre=/sbin/chroot --userspec=nginx:nginx /chroot/nginx /usr/sbin/nginx -t -q (code=exited, status=0/SUCCESS) Main PID: 24679 (nginx) CGroup: /system.slice/nginx-chroot.service ├─24679 nginx: master process /usr/sbin/nginx └─24680 nginx: worker process
nginx 24679 0.0 0.0 45824 1124 ? Ss 23:21 0:00 nginx: master process /usr/sbin/nginxnginx 24680 0.0 0.1 46344 2168 ? S 23:21 0:00 nginx: worker process
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 24679/nginx: master
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Nginx Chroot/chroot/nginx/├── dev│ ├── null│ ├── random│ └── urandom├── etc│ ├── group│ ├── gshadow│ ├── host.conf│ ├── hosts│ ├── ld.so.cache│ ├── ld.so.conf│ ├── localtime│ ├── nginx│ │ ├── conf.d│ │ │ ├── default│ │ │ ├── example_ssl.conf│ │ │ └── test.conf│ │ ├── fastcgi_params│ │ ├── koi-utf│ │ ├── koi-win│ │ ├── mime.types│ │ ├── nginx.conf│ │ ├── scgi_params│ │ ├── uwsgi_params│ │ └── win-utf│ ├── nsswitch.conf│ ├── passwd│ ├── protocols│ ├── resolv.conf│ ├── services│ ├── shadow│ ├── shells│ └── sysconfig│ └── nginx
├── lib64 -> usr/lib64/├── proc├── run├── sbin -> usr/sbin/├── srv-www│ └── test│ ├── index.html│ └── info.php├── sys├── tmp├── usr│ ├── lib64│ │ ├── ld-linux-x86-64.so.2│ │ ├── libcom_err.so.2│ │ ├── libcrypto.so.10│ │ ├── libcrypt.so.1│ │ ├── libc.so.6│ │ ├── libdl.so.2│ │ ├── libfreebl3.so│ │ ├── libgssapi_krb5.so.2│ │ ├── libk5crypto.so.3│ │ ├── libkeyutils.so.1│ │ ├── libkrb5.so.3│ │ ├── libkrb5support.so.0│ │ ├── liblzma.so.5│ │ ├── libnss_files-2.17.so│ │ ├── libnss_files.so.2 -> libnss_files-2.17.so│ │ ├── libpcre.so.1│ │ ├── libpthread.so.0│ │ ├── libresolv.so.2│ │ ├── libselinux.so.1│ │ ├── libssl.so.10│ │ └── libz.so.1│ ├── sbin│ │ ├── nginx│ │ └── nologin
│ └── share│ └── nginx│ └── html│ ├── 50x.html│ ├── index.html│ └── test -> /chroot/nginx/srv-www/test/└── var ├── cache │ └── nginx │ ├── client_temp │ ├── fastcgi_temp │ ├── proxy_temp │ ├── scgi_temp │ └── uwsgi_temp ├── log │ └── nginx │ ├── error.log │ ├── test.access.log │ └── test.error └── run -> ../run/
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
PHP-FPM Chroot
FPM(FastCGI Process Manager) PHPFastCGI'a alternatif ve bazı ek özellikler eklenmişhalidir.
CentOS7 sürümü resmi depolarında PHP-FPM bulunduğundan ek bir depo ekleme vb.Gibi işlemler yapmaya gerek bulunmamaktadır.
yum install php-fpm
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
PHP-FPM Chroot
[test]listen = 127.0.0.1:9000listen.allowed_clients = 127.0.0.1
user = nginxgroup = nginx
pm = dynamicpm.max_children = 50pm.start_servers = 5pm.min_spare_servers = 5pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
chroot = /chroot/php-fpmchdir = /php_admin_value[disable_functions] = dir,chdir,opendir,readdirphp_admin_value[error_log] = /var/log/php-fpm/test-error.logphp_admin_flag[log_errors] = onphp_admin_value[error_reporting] = E_ALL & ~E_NOTICE
php_value[session.save_handler] = filesphp_value[session.save_path] = /var/lib/php/session
/etc/php-fpm.d/test.conf
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
PHP-FPM ChrootChroot için gerekli dizinler
[root@aek ~]# cd /[root@aek ~]# mkdir /chroot/php-fpm[root@aek ~]# mkdir /chroot/php-fpm/dev[root@aek ~]# mkdir /chroot/php-fpm/etc[root@aek ~]# mkdir /chroot/php-fpm/lib64[root@aek ~]# mkdir /chroot/php-fpm/srv-www[root@aek ~]# mkdir /chroot/php-fpm/srv-www/test[root@aek ~]# mkdir /chroot/php-fpm/usr[root@aek ~]# mkdir /chroot/php-fpm/usr/lib64[root@aek ~]# mkdir /chroot/php-fpm/usr/share[root@aek ~]# mkdir /chroot/php-fpm/usr/share/zoneinfo[root@aek ~]# mkdir /chroot/php-fpm/var/share/zoneinfo/Europe
mknod -m 0444 /chroot/nginx/dev/urandom c 1 9
Chroot için gerekli cihazlar
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
PHP-FPM Chroot
├── dev│ └── urandom├── etc│ ├── host.conf│ ├── hosts│ ├── localtime -> ../usr/share/zoneinfo/Europe/Istanbul│ └── resolv.conf├── lib64│ ├── libnss_dns-2.17.so│ └── libnss_dns.so.2 -> libnss_dns-2.17.so├── srv-www│ └── test│ ├── index.html│ └── info.php└── usr ├── lib64 │ └── libsoftokn3.so └── share └── zoneinfo ├── Europe │ └── Istanbul └── zone.tab
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
PHP-FPM Chroot
[test]listen = 127.0.0.1:9000listen.allowed_clients = 127.0.0.1
user = nginxgroup = nginx
pm = dynamicpm.max_children = 50pm.start_servers = 5pm.min_spare_servers = 5pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/test-slow.log
chroot = /chroot/php-fpmchdir = /php_admin_value[disable_functions] = dir,chdir,opendir,readdirphp_admin_value[error_log] = /var/log/php-fpm/test-error.logphp_admin_flag[log_errors] = onphp_admin_value[error_reporting] = E_ALL & ~E_NOTICE
php_value[session.save_handler] = filesphp_value[session.save_path] = /var/lib/php/session
/etc/php-fpm.d/test.conf
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
PHP-FPM Chroot
location ~ \.php$ { try_files $uri = 404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }
/etc/nginx/conf.d/test.conf
Özgür Yazılım ve Linux Günleri 2015 - Istanbul / 27.03.2015
Sonuç ve sorular ??
Ali Erdinç KöroğluAli Erdinç Köroğlu
[email protected] - http://ae.koroglu.org - - http://twitter.com/erdinc