Erinevus lehekülje "PHP käivitamine kasutaja õigustes" redaktsioonide vahel
1. rida: | 1. rida: | ||
− | |||
cd /usr/ports ..apache2 | cd /usr/ports ..apache2 | ||
make with_suexec_modules=yes | make with_suexec_modules=yes | ||
5. rida: | 4. rida: | ||
2r4# suexec -V | 2r4# suexec -V | ||
-D AP_DOC_ROOT="/usr/local/www/data" | -D AP_DOC_ROOT="/usr/local/www/data" | ||
− | -D AP_GID_MIN=1000 | + | -D AP_GID_MIN=1000 |
-D AP_HTTPD_USER="www" | -D AP_HTTPD_USER="www" | ||
-D AP_LOG_EXEC="/var/log/httpd-suexec.log" | -D AP_LOG_EXEC="/var/log/httpd-suexec.log" | ||
13. rida: | 12. rida: | ||
− | + | ei hakka DOC_ROOT muutma nagu n2ha ylevalt asub see hetkel /usr/local/www/data ehitasin sinna kiirelt. | |
muudame httpd.conf | muudame httpd.conf | ||
− | + | LoadModule suexec_module libexec/apache2/mod_suexec.so | |
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | tekitasin veel konfi sellise jubina..ilma ei k2inud | ||
− | + | <IfModule mod_fastcgi.c> | |
+ | FastCgiWrapper /usr/local/sbin/suexec | ||
+ | FastCgiConfig -singleThreshold 1 -pass-header HTTP_AUTHORIZATION | ||
+ | AddHandler fastcgi-script .fcgi .fcg .fpl> | ||
+ | AddType application/x-httpd-php5 .php .php5 | ||
+ | AddType application/x-httpd-php4 .php4 | ||
+ | </IfModule> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | tekitasin virtualhostid | |
− | <VirtualHost | + | <VirtualHost *:80> |
SuexecUserGroup katse katse | SuexecUserGroup katse katse | ||
− | ServerAdmin | + | ServerAdmin kasutaja@nimi.ee |
DocumentRoot /usr/local/www/data/katse | DocumentRoot /usr/local/www/data/katse | ||
− | ServerName test. | + | ServerName www.nimi.ee |
+ | |||
+ | ScriptAlias /php-fastcgi/ /usr/local/www/data/katse/ | ||
+ | AddType application/x-httpd-fastphp .php | ||
+ | Action application/x-httpd-fastphp /php-fastcgi/php5-fcgi | ||
+ | |||
+ | </VirtualHost> | ||
+ | |||
+ | <VirtualHost *:80> | ||
+ | SuexecUserGroup katse3 katse3 | ||
+ | ServerAdmin kasutaja@nimi.ee | ||
+ | DocumentRoot /usr/local/www/data/katse3/cgi-bin | ||
+ | ServerName test.nimi.ee | ||
+ | |||
+ | ScriptAlias /php-fastcgi/ /usr/local/www/data/katse3/cgi-bin | ||
+ | AddType application/x-httpd-fastphp .php | ||
+ | Action application/x-httpd-fastphp /php-fastcgi/php5-fcgi | ||
+ | |||
+ | </VirtualHost> | ||
− | |||
− | |||
− | |||
− | + | viimaks ehitame skripti | |
− | + | #!/bin/sh | |
− | + | #PHPRC="/usr/local/etc/php.ini" | |
− | + | export PHPRC | |
− | + | PHP_FCGI_CHILDREN=4 | |
− | + | export PHP_FCGI_CHILDREN | |
− | + | exec /usr/local/bin/php-cgi | |
− | |||
− | |||
− | |||
− | |||
− | |||
kopeerime selle faili kasutajate katse ja katse 3 kaustadesse ja teeme chown mõlemale failile kasutaja õigusesse | kopeerime selle faili kasutajate katse ja katse 3 kaustadesse ja teeme chown mõlemale failile kasutaja õigusesse | ||
+ | /usr/local/www/data/katse/cgi-bin/php5-fcgi | ||
+ | /usr/local/www/data/katse3/cgi-bin/php5-fcgi | ||
+ | |||
+ | chown katse:katse /usr/local/www/data/katse/cgi-bin/php5-fcgi | ||
+ | chown katse3:katse3 /usr/local/www/data/katse3/cgi-bin/php5-fcgi | ||
+ | |||
+ | |||
+ | testimiseks saab teha skripti | ||
+ | |||
+ | <?php | ||
+ | print "hello world<p>\n"; | ||
+ | system("id"); | ||
+ | php?> | ||
+ | |||
+ | |||
+ | www.nimi.ee skripti vaadates | ||
+ | |||
+ | hello world | ||
+ | |||
+ | uid=1004(katse) gid=1004(katse) groups=1004(katse) | ||
+ | |||
+ | test.nimi.ee | ||
+ | |||
+ | hello world | ||
+ | |||
+ | uid=1009(katse3) gid=1009(katse3) groups=1009(katse3) | ||
+ | |||
− | + | EENet 2006 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Redaktsioon: 12. september 2006, kell 09:12
cd /usr/ports ..apache2 make with_suexec_modules=yes
2r4# suexec -V -D AP_DOC_ROOT="/usr/local/www/data" -D AP_GID_MIN=1000 -D AP_HTTPD_USER="www" -D AP_LOG_EXEC="/var/log/httpd-suexec.log" -D AP_SAFE_PATH="/usr/local/bin:/usr/local/bin:/usr/bin:/bin" -D AP_UID_MIN=1000 -D AP_USERDIR_SUFFIX="public_html"
ei hakka DOC_ROOT muutma nagu n2ha ylevalt asub see hetkel /usr/local/www/data ehitasin sinna kiirelt.
muudame httpd.conf
LoadModule suexec_module libexec/apache2/mod_suexec.so
tekitasin veel konfi sellise jubina..ilma ei k2inud
<IfModule mod_fastcgi.c> FastCgiWrapper /usr/local/sbin/suexec FastCgiConfig -singleThreshold 1 -pass-header HTTP_AUTHORIZATION
AddHandler fastcgi-script .fcgi .fcg .fpl> AddType application/x-httpd-php5 .php .php5 AddType application/x-httpd-php4 .php4 </IfModule>
tekitasin virtualhostid
<VirtualHost *:80> SuexecUserGroup katse katse ServerAdmin kasutaja@nimi.ee DocumentRoot /usr/local/www/data/katse ServerName www.nimi.ee ScriptAlias /php-fastcgi/ /usr/local/www/data/katse/ AddType application/x-httpd-fastphp .php Action application/x-httpd-fastphp /php-fastcgi/php5-fcgi </VirtualHost>
<VirtualHost *:80> SuexecUserGroup katse3 katse3 ServerAdmin kasutaja@nimi.ee DocumentRoot /usr/local/www/data/katse3/cgi-bin ServerName test.nimi.ee ScriptAlias /php-fastcgi/ /usr/local/www/data/katse3/cgi-bin AddType application/x-httpd-fastphp .php Action application/x-httpd-fastphp /php-fastcgi/php5-fcgi </VirtualHost>
viimaks ehitame skripti
#!/bin/sh #PHPRC="/usr/local/etc/php.ini" export PHPRC PHP_FCGI_CHILDREN=4 export PHP_FCGI_CHILDREN exec /usr/local/bin/php-cgi
kopeerime selle faili kasutajate katse ja katse 3 kaustadesse ja teeme chown mõlemale failile kasutaja õigusesse /usr/local/www/data/katse/cgi-bin/php5-fcgi /usr/local/www/data/katse3/cgi-bin/php5-fcgi
chown katse:katse /usr/local/www/data/katse/cgi-bin/php5-fcgi chown katse3:katse3 /usr/local/www/data/katse3/cgi-bin/php5-fcgi
testimiseks saab teha skripti
<?php
print "hello world
\n"; system("id"); php?> www.nimi.ee skripti vaadates hello world uid=1004(katse) gid=1004(katse) groups=1004(katse) test.nimi.ee hello world uid=1009(katse3) gid=1009(katse3) groups=1009(katse3) EENet 2006