I am using Debian Squeeze and set up PHP-FPM with fastcgi. I have several virtual hosts defined on the same host. I defined chroot for each pool configuration but somehow it is possible to change directory and go above the root directory definition at the pool conf.
disable_functions at the conf file is not working as well. I haven't figured it out the reason.
Sample files are below:
/etc/php5/fpm/pool.d/foo.conf:
[foo]
user = foo
group = foo
listen = 127.0.0.1:9018
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chroot = /var/www/foo
chdir = /
php_admin_value[disable_functions] = dir,chdir,opendir,readdir
php_admin_value[doc_root] = /var/www/foo
php_admin_value[open_basedir] = /var/www/foo
access.log = /var/log/$pool.access.log
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
/etc/apache2/sites-enables/foo.com:
<VirtualHost 19x.xxx.xxx.xx>
DocumentRoot /var/www/foo
ServerName foo.com
<IfModule mod_fastcgi.c>
FastCgiExternalServer /foocgi/php5-wrapper -host 127.0.0.1:9018 -user foouser -group foogroup
ScriptAlias /foocgi/ /var/www/foo/cgi-bin/
AddHandler php5-fastcgi .php
Action php5-fastcgi /foocgi/php5-wrapper
AddType application/x-httpd-php .php
<Directory /var/www/foo/cgi-bin/>
SetHandler fastcgi-script
Options +ExecCGI
</Directory>
</IfModule>
<Directory /var/www/foo>
allow from all
Options -Indexes SymLinksIfOwnerMatch
</Directory>
</VirtualHost>
/var/www/foo/cgi-bin/php5-wrapper:
#!/bin/sh
PHPRC=/etc/php5/cgi/
export PHPRC
#export PHP_FCGI_MAX_REQUESTS=5000
#export PHP_FCGI_CHILDREN=8
exec /usr/lib/cgi-bin/php
/etc/apache2/mods-enabled/fastcgi.conf:
<IfModule mod_fastcgi.c>
FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240 -maxClassProcesses 1 -pass-header HTTP_AUTHORIZATION
FastCgiWrapper /usr/lib/apache2/suexec
<Directory "/var/www/cgi-bin/">
AllowOverride none
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</IfModule>
/var/log/foo.access.log is empty though port 9018 is LISTEN at netstat output. The site is being opened without errors also. Any idea about the chroot problem or how to make the disable_functions work?
Can you show your phpinfo()?
May you load PHP.ini from /etc/php5/cgi/php.ini and from your php-fpm config, from pool.d/* or from /etc/php5/fpm/php.ini
I say that for:
#!/bin/sh
PHPRC=/etc/php5/cgi/
export PHPRC
#export PHP_FCGI_MAX_REQUESTS=5000
#export PHP_FCGI_CHILDREN=8
exec /usr/lib/cgi-bin/php
php5-fpm is usually in /usr/sbin/php5-fpm
Related
I am unfamiliar with Apache2 - I want to find out where the logs are going - I have this apache2.conf contents:
ServerName 0.0.0.0
ErrorLog /dev/stderr
TransferLog /dev/stdout
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog /dev/stderr
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory "/*" >
#Options FollowSymLinks
#AllowOverride None
#Require all denied
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-available/*.conf
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
and these envvars:
unset HOME
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
SUFFIX=
fi
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
export LANG=C
. /etc/default/locale
export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib/:$LD_LIBRARY_PATH
export NLTK_DATA=/nltk_data
does anyone know if any logs will be populated other than the logs in /var/log/apache2/*?
httpd -V or apache2ctl -V will tell you the log locations in use, there are not more locations other than that.
You should know that:
/dev/stdout is a special path that redirect everything you
write to the standard out of the process
/dev/stderr same as abobe but redirect to standard error of the
process
/dev/null same as abobe but instead of redirect, it just
discards
Extra: The default apache2 logs location is not equal to every O.S. and in some of them envvars file don't exist.
I want to create site in the same IP but with different sub folder, for example:
http://192.168.0.1/a/ --> /var/www/site_a/
http://192.168.0.1/b/ --> /var/www/site_b/
The config:
<VirtualHost *:80>
#Site name
ServerName 192.168.0.1
#Root folder
DocumentRoot /var/www/site_a/
#log
ErrorLog /var/www/binapk/logs/error.log
#Access log
CustomLog /var/www/binapk/logs/access.log combined
Alias /a /var/www/site_a/
Alias /b /var/www/site_b/
</VirtualHost>
But if you enter http://192.168.0.1 (without /a or /b), it will show the same page as http://192.168.0.1/a/, I want http://192.168.0.1/ is nothing show up.
How to do that?
The few lines that you have specifying the DocumentRoot:
#Root folder
DocumentRoot /var/www/site_a/
are pointing your http://192.169.0.1/ to the /a folder, you would want to point it at something else in order to have it load a different document.
How do I add following string to batch file for add it to a file?
<VirtualHost *:80>
ServerAdmin webmaster#mydomain.dev
DocumentRoot "J:\repo\mydomain"
ServerName mydomain.dev
ErrorLog "logs/mydomain.dev-error.log"
CustomLog "logs/mydomain.dev-access.log" common
<Directory "J:\repo\mydomain">
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
This is what I'm trying to achieve
#echo off
set /p DomName=Enter Domain Name:
Echo "<VirtualHost *:80>
ServerAdmin webmaster#mydomain.dev
DocumentRoot "J:\repo\mydomain"
ServerName mydomain.dev
ErrorLog "logs/mydomain.dev-error.log"
CustomLog "logs/mydomain.dev-access.log" common
<Directory "J:\repo\mydomain">
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>" >> "J:\xampp\apache\conf\extra\httpd-vhosts.conf"
:End
I want to replace "DomName" variable inside the string.
Thank you!!!
You need to Echo each line individually.
Simply use %domname% where you want to substitute the inputted text.
If you use the syntax
(
echo something
echo something else
)>somefilename
then a new file will be created containing the text that would have been echoed. If you want to append to anexisting file, use >> in place of >
You need to "escape" some characters which have special meaning to batch. If you want a literal > you need to code ^> if you want the literal text to be produced. Same comment for <
I have apache virtualhost:
<VirtualHost IP_WAN:80>
ServerName test.localnet
DocumentRoot /srv/http/localnet/test/trunk/docroot
<Directory /srv/http/localnet/test/trunk/docroot>
Options Indexes
</Directory>
</VirtualHost>
The partition /srv is NFS3 mounted filesystem:
172.16.0.2:/srv /srv nfs nodev 0 0
at the server-side it's exported by:
/srv 172.16.0.0/255.255.255.240(rw,sync,no_subtree_check,no_root_squash)
directory /srv/http/localnet/test/trunk is absolute symlink to /srv/http/localnet/test/exports/trunk-v2
In the /srv/http/localnet/test/exports I have exported SVN trees (trunk-v1, trunk-v2, trunk-v3)
When I ask apache for http://test.localnet, it serves 200 OK and index from /srv/http/localnet/test/exports/trunk-v2/docroot
BUT:
If I remove symlink /srv/http/localnet/test/trunk and create a new one to another version (ln -s /srv/http/localnet/test/exports/trunk-v3 /srv/http/localnet/test/trunk), apache gives me 404 Not Found. It takes about seconds/minutes, then everything goes back to normal itself.
If I do ls -la /srv/http/localnet/test/trunk/ in this condition, it goes back to normal immediately. I think there's some problem with NFS cache, but I'm not able to find where exactly the problem occurs and how to prevent it. The symlink occupies the same inode as the previous one, both of targets (the old one and the new one) exists.
On the server side I have /srv partition mounted this way:
/dev/xvda7 on /srv type xfs (rw,nosuid,nodev)
I also use this parameters:
echo 262144 >/proc/sys/net/core/rmem_max
echo 262144 >/proc/sys/net/core/rmem_default
echo 262144 >/proc/sys/net/core/wmem_max
echo 262144 >/proc/sys/net/core/wmem_default
echo noop >/sys/block/xvda7/queue/scheduler
echo 0 >/sys/block/xvda7/queue/read_ahead_kb
I'm also trying to tune MTU of the network interface up to 9000, but without success.
Does anybody know, what's the problem? Why apache can't find the symlink until 'manually' refresh of the directory structure (ls)? Thanks a lot
Ondra
The solution seems to be:
http://publib.boulder.ibm.com/httpserv/manual70/mod/core.html#enablemmap
"With an NFS-mounted DocumentRoot, the httpd may crash due to a segmentation fault if a file is deleted or truncated while the httpd has it memory-mapped"
This is exactly the situation, when removing the symlink in the path to the page.
Hope it helps others :-)
I want to pass envrionment varaable to the apcahe2 server...
I have exported PATH Var in .bashrc file
now i want to pass it to the server...
I inserted this line 'PassEnv PATH ' to my apache.conf file..
PassEnv PATH
ScriptAlias /cgi-bin/ /home/abc/cgi-bin/
<Directory "/home/abc/cgi-bin">
Options +ExecCGI
Allow from all
</Directory>
but it still not identifying the this variable...
Pl Help me how to pass this Env var to the server..
Thanks
SetEnv APPLICATION_ENV "development"
Should do the trick. The syntax is: SetEnv Key *Value*