Table of Contents

Wstęp

Apache z PHP, które jest przepuszczone przez mod_fcgid (zamiast mod_php) z uprawnieniami użytkownika (suexec).

Instalacja

poldek:/all-avail> install apache apache-mod_dir apache-mod_fcgid apache-mod_autoindex apache-suexec php-common php-fcgi

Log instalacji dostępny tutaj dla porównania w razie błędów link.

Konfiguracja

Skonfigurujemy przykładowego vhost'a o nazwie: test.com.pl .

Ulubionym edytorem tworzymy i edytujemy plik: /etc/httpd/vhosts.d/test.com.pl.conf:

<VirtualHost *:80>

        SuexecUserGroup kamil users

        ErrorLog /home/services/httpd/users/kamil/test.com.pl/error.log
        TransferLog /home//services/httpd/users/kamil/test.com.pl/access.log

        <Directory /home/services/httpd/users/kamil/test.com.pl/htdocs>
                Options ExecCGI Indexes Includes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
                AddHandler fcgid-script .php
                FCGIWrapper /home/services/httpd/users/kamil/test.com.pl/fcgid/php.fcgi .php
        </Directory>

        ServerAdmin kamil@test.com.pl
        DocumentRoot /home/services/httpd/users/kamil/test.com.pl/htdocs

        ServerName test.com.pl

</VirtualHost>

Dodajemy przykładowego użytkownika jeśli takowego nie mamy. Ja dla przykładu nadam jemu login: kamil .

Tworzymy strukturę pod vhosty użytkowników:

$ mkdir -p /home/services/httpd/users/kamil/test.com.pl/{htdocs,tmp,fcgid}
$ chown root:root /home/services/httpd/users
$ chmod 711 /home/services/httpd/users

Struktura pod vhosta test.com.pl:

$ chown -R kamil:http /home/services/httpd/users/kamil
$ chmod -R 710 /home/services/httpd/users/kamil
$ chown kamil:http /home/services/httpd/users/kamil/test.com.pl/{htdocs,tmp}
$ chmod -R 750 /home/services/httpd/users/kamil/test.com.pl/{htdocs,tmp}
$ chown kamil:users /home/services/httpd/users/kamil/test.com.pl/fcgid
$ chmod -R 711 /home/services/httpd/users/kamil/test.com.pl/fcgid

Tworzymy symboliczny link, aby użytkownik z katalogu domowego nie musiał bładzić po katalogach:

$ ln -s /home/services/httpd/users/kamil/ /home/users/kamil/www

Ulubionym edytorem tworzymy i edytujemy plik: /home/services/httpd/users/kamil/test.com.pl/fcgid/php.fcgi:

#!/bin/sh

export PHP_FCGI_CHILDREN=4
export PHP_FCGI_MAX_REQUESTS=500
exec /usr/bin/php.fcgi $@

Nadajemy uprawnienia:

$ chmod 700 /home/services/httpd/users/kamil/test.com.pl/fcgid/php.fcgi
$ chown kamil:users /home/services/httpd/users/kamil/test.com.pl/fcgid/php.fcgi

Ulubionym edytorem tworzymy i edytujemy plik: /home/services/httpd/users/kamil/test.com.pl/htdocs/info.php:

<?php

echo phpinfo();

?>

Uruchamiamy Apacha:

$ /etc/init.d/httpd start
Uruchamianie usługi Apache 2.2 Web Server (prefork)................[ ZROBIONE ]

Wchodzimy na stronę: http://test.com.pl/ i przechodzimy do pliku info.php - powinna nam pojawić się tabelka informacyjna PHP'a. W systemie sprawdzamy czy proces uruchomił się z prawami użytkownika:

$ ps aux | grep httpd
root      2508  0.0  0.7   7988  3936 ?        SNs  15:28   0:00 /usr/sbin/httpd.prefork
http      2512  0.0  0.4   7924  2276 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2513  0.0  0.4   7988  2252 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2514  0.0  0.5   8192  2940 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2515  0.0  0.4   7988  2240 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2516  0.0  0.5   8120  2756 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2517  0.0  0.5   8120  2844 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2518  0.0  0.4   7988  2240 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2519  0.0  0.4   7988  2240 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
http      2520  0.0  0.4   7988  2240 ?        SN   15:28   0:00 /usr/sbin/httpd.prefork
root      2568  0.0  0.1   2808   844 pts/0    S+   15:53   0:00 grep httpd
$ [root@pld_fcgid /]# pstree -up 2508
httpd.prefork(2508)-+-httpd.prefork(2512,http)---php.fcgi(2526,kamil)-+-php.fcgi(2527)
                    |                                                 |-php.fcgi(2528)
                    |                                                 |-php.fcgi(2529)
                    |                                                 `-php.fcgi(2530)
                    |-httpd.prefork(2513,http)
                    |-httpd.prefork(2514,http)
                    |-httpd.prefork(2515,http)
                    |-httpd.prefork(2516,http)
                    |-httpd.prefork(2517,http)
                    |-httpd.prefork(2518,http)
                    |-httpd.prefork(2519,http)
                    `-httpd.prefork(2520,http)

Pliki

pl/przewodniki/apache-php-fcgid-suexec.txt · Last modified: 2010/05/11 18:18 by nospe
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0 Powered by Lighttpd - fly light