php-fpm show script instead of execute them - php

I'm installing sympa 6.2.42 on a ubuntu server 18.04 with php 7.2 and fpm and apache 2.4.29 (installed with official packages)
Sympa is installed from the source.
My virtual host under apache should normally run a fcgi script with fpm.
The problem is that my script is displayed in clear on my web page. The fcgi is therefore not executed, just displayed.
No errors in the logs (fpm/apache/syslog). The fpm/apache/sympa services runs normally.
I have change my script to a simple 'hello world', result is the same.
This is my virtual host:
<VirtualHost *:80>
Servername mycomputer.mydomain.com
Serveradmin step#mydomain.com
Documentroot /var/www/sympa.mydomain.com
<Location /sympa>
SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://"
Options +ExecCGI
Require all granted
</Location>
<Location /static-sympa>
Require all granted
</Location>
alias /static-sympa /appli/sympa/static-content
ScriptAlias /sympa /appli/sympa/lib/sympa/cgi/wwsympa-wrapper.fcgi
RewriteEngine on
RewriteRule ^/$ /sympa [R,L]
</VirtualHost>
The output is the content of the wwsympa-wrapper.fcgi.
wwsympa-wrapper is not execute.
Update 1
My apache log:
[Thu May 23 08:41:53.760226 2019] [authz_core:debug] [pid 17536:tid 139860299998976] mod_authz_core.c(809): [client XX.XX.XX.X:53422] AH01626: authorization result of Require all granted: granted
[Thu May 23 08:41:53.760287 2019] [authz_core:debug] [pid 17536:tid 139860299998976] mod_authz_core.c(809): [client XX.XX.XX.X:53422] AH01626: authorization result of <RequireAny>: granted
[Thu May 23 08:41:53.760309 2019] [proxy:debug] [pid 17536:tid 139860299998976] mod_proxy.c(1228): [client XX.XX.XX.X:53422] AH01143: Running scheme unix handler (attempt 0)
[Thu May 23 08:41:53.760323 2019] [proxy_fcgi:debug] [pid 17536:tid 139860299998976] mod_proxy_fcgi.c(995): [client XX.XX.XX.X:53422] AH01076: url: fcgi:///appli/sympa/lib/sympa/cgi/wwsympa-wrapper.fcgi proxyname: (null) proxyport: 0
[Thu May 23 08:41:53.760331 2019] [proxy_fcgi:debug] [pid 17536:tid 139860299998976] mod_proxy_fcgi.c(1002): [client XX.XX.XX.X:53422] AH01078: serving URL fcgi:///appli/sympa/lib/sympa/cgi/wwsympa-wrapper.fcgi
[Thu May 23 08:41:53.760336 2019] [proxy:debug] [pid 17536:tid 139860299998976] proxy_util.c(2162): AH00942: FCGI: has acquired connection for (*)
[Thu May 23 08:41:53.760345 2019] [proxy:debug] [pid 17536:tid 139860299998976] proxy_util.c(2215): [client XX.XX.XX.X:53422] AH00944: connecting fcgi:///appli/sympa/lib/sympa/cgi/wwsympa-wrapper.fcgi to :8000
[Thu May 23 08:41:53.760349 2019] [proxy:debug] [pid 17536:tid 139860299998976] proxy_util.c(2252): [client XX.XX.XX.X:53422] AH02545: fcgi: has determined UDS as /var/run/php/php7.2-fpm.sock
[Thu May 23 08:41:53.760398 2019] [proxy:debug] [pid 17536:tid 139860299998976] proxy_util.c(2424): [client XX.XX.XX.X:53422] AH00947: connected /appli/sympa/lib/sympa/cgi/wwsympa-wrapper.fcgi to httpd-UDS:0
[Thu May 23 08:41:53.760432 2019] [proxy:debug] [pid 17536:tid 139860299998976] proxy_util.c(2795): AH02823: FCGI: connection established with Unix domain socket /var/run/php/php7.2-fpm.sock (*)
[Thu May 23 08:41:53.761132 2019] [proxy:debug] [pid 17536:tid 139860299998976] proxy_util.c(2177): AH00943: FCGI: has released connection for (*)
[Thu May 23 08:41:53.761265 2019] [deflate:debug] [pid 17536:tid 139860299998976] mod_deflate.c(853): [client XX.XX.XX.X:53422] AH01384: Zlib: Compressed 10632 to 3341 : URL /sympa

This is not php-fpm who is returning the script.
This behavior is generated because your configuration is wrong.
php-fpm work as a CGI gateway and you need to tell Apache to send .php file to it in order to be executed.
In your case, Apache does not know where to send this .php file and return simply the page as text.
I suggest to go here for install php-fpm properly with Apache
EDIT :
The configuration in Sympa documentation look like this :
<Location /sympa>
SetHandler "proxy:unix:$PIDDIR/wwsympa.socket|fcgi://"
Require all granted
</Location>
<Location /static-sympa>
Require all granted
</Location>

Related

Redirect requests to Django application using Apache

I have an Apache web-server and a PHP application. It all works great. The httpd.conf file at this moment looks like so:
...
LoadModule wsgi_module modules/mod_wsgi.so
...
Listen 8080
DocumentRoot "c:/Apache242/htdocs"
<Directory "c:/Apache242/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
As you can see, I've already downloaded mod_wsgi.so and when I restart Apache it's all ok. So, when I go to localhost:8080, I see my PHP application running. Well done. Now, I have a second teene-weeny Django application. It's not even a full-blown application, because it's role will be to answer to one certain request from the same PHP application. Still, I will call it Django application. I run it like so:
C:\django\project> python manage.py runserver 127.0.0.1:8081
As you can see I run a non-production server, but it works good. When I go to 127.0.0.1:8081, I see the result returned from my index view:
def index(request):
return HttpResponse("Hello, world")
So, it's just a simple Hello world page and it works. Now what I want is to use Apache server, so that when I go to localhost:8080/django, I would see the very same Hello world page. I do not know how to implement this. Many solutions are based on virtual hosts, but I do not want to configure them (just because virtual hosts do not work in my situation). So if you have any suggestions, you are welcome. Thanks!
EDIT
I managed to create a virtual host for my PHP application. So, the httpd-vhosts.conf file looks like so:
Listen 8080
<VirtualHost *:8080>
DocumentRoot "c:/Apache242/htdocs"
<Directory c:/Apache242/htdocs>
Options Indexes FollowSymLinks
AllowOverride None
Order Deny,Allow
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
Now I wonder, how I should configure it to redirect requests from localhost:8080/django to my Django application.
EDIT
It seems like I tried everything in the world. Now I've just tried to create one and only one virtual host just to service my Django project and I failed. Here are some prerequisites that I have:
Python 2.7.12, MSC 1500 32bit on win32.
Apache/2.4.23 (Win64), VC10
mod_wsgi-py27-VC9.so for Apache24-win64-VC10
And this is how my virtual host file looks like now:
Listen 8080
<VirtualHost *:8080>
DocumentRoot "C:/Apache242/htdocs/django"
ServerName localhost
WSGIScriptAlias / "C:/Apache242/htdocs/django/accent/wsgi.py"
<Directory "C:/Apache242/htdocs/django/accent">
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
When I reload Apache, I see it's all ok. Great. But when I go to localhost:8080, I get "Internal Server Error". And this is the whole stack trace from Apache error log:
[Fri Dec 02 14:02:33.340929 2016] [mpm_winnt:notice] [pid 8212:tid 300] AH00430: Parent: Child process 9532 exited successfully.
[Fri Dec 02 14:02:34.241980 2016] [wsgi:warn] [pid 4652:tid 300] mod_wsgi: Compiled for Python/2.7.9+.
[Fri Dec 02 14:02:34.242980 2016] [wsgi:warn] [pid 4652:tid 300] mod_wsgi: Runtime using Python/2.7.6.
[Fri Dec 02 14:02:34.242980 2016] [mpm_winnt:notice] [pid 4652:tid 300] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.4.6 Python/2.7.6 configured -- resuming normal operations
[Fri Dec 02 14:02:34.242980 2016] [mpm_winnt:notice] [pid 4652:tid 300] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Fri Dec 02 14:02:34.242980 2016] [core:notice] [pid 4652:tid 300] AH00094: Command line: 'C:\\Apache242\\bin\\httpd.exe -d C:/Apache242'
[Fri Dec 02 14:02:34.245981 2016] [mpm_winnt:notice] [pid 4652:tid 300] AH00418: Parent: Created child process 10960
[Fri Dec 02 14:02:34.695006 2016] [wsgi:warn] [pid 10960:tid 172] mod_wsgi: Compiled for Python/2.7.9+.
[Fri Dec 02 14:02:34.696006 2016] [wsgi:warn] [pid 10960:tid 172] mod_wsgi: Runtime using Python/2.7.6.
[Fri Dec 02 14:02:34.753010 2016] [mpm_winnt:notice] [pid 10960:tid 172] AH00354: Child: Starting 64 worker threads.
[Fri Dec 02 14:02:54.295127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] mod_wsgi (pid=10960): Target WSGI script 'C:/Apache24/htdocs/django/accent/wsgi.py' cannot be loaded as Python module.
[Fri Dec 02 14:02:54.295127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] mod_wsgi (pid=10960): Exception occurred processing WSGI script 'C:/Apache24/htdocs/django/accent/wsgi.py'.
[Fri Dec 02 14:02:54.295127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] Traceback (most recent call last):
[Fri Dec 02 14:02:54.295127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:/Apache24/htdocs/django/accent/wsgi.py", line 13, in <module>
[Fri Dec 02 14:02:54.296127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] from django.core.wsgi import get_wsgi_application
[Fri Dec 02 14:02:54.296127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\core\\wsgi.py", line 2, in <module>
[Fri Dec 02 14:02:54.296127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] from django.core.handlers.wsgi import WSGIHandler
[Fri Dec 02 14:02:54.296127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\core\\handlers\\wsgi.py", line 11, in <module>
[Fri Dec 02 14:02:54.297127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] from django import http
[Fri Dec 02 14:02:54.297127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\http\\__init__.py", line 1, in <module>
[Fri Dec 02 14:02:54.297127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] from django.http.cookie import SimpleCookie, parse_cookie
[Fri Dec 02 14:02:54.297127 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\http\\cookie.py", line 3, in <module>
[Fri Dec 02 14:02:54.298128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] from django.utils.encoding import force_str
[Fri Dec 02 14:02:54.298128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\utils\\encoding.py", line 10, in <module>
[Fri Dec 02 14:02:54.298128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] from django.utils.six.moves.urllib.parse import quote
[Fri Dec 02 14:02:54.298128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\utils\\six.py", line 90, in __get__
[Fri Dec 02 14:02:54.299128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] result = self._resolve()
[Fri Dec 02 14:02:54.299128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\utils\\six.py", line 158, in _resolve
[Fri Dec 02 14:02:54.299128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] module = _import_module(self.mod)
[Fri Dec 02 14:02:54.299128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\lib\\site-packages\\django-1.7.11-py2.7.egg\\django\\utils\\six.py", line 80, in _import_module
[Fri Dec 02 14:02:54.299128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] __import__(name)
[Fri Dec 02 14:02:54.299128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\Lib\\urllib.py", line 26, in <module>
[Fri Dec 02 14:02:54.301128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] import socket
[Fri Dec 02 14:02:54.301128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] File "C:\\Python27\\Lib\\socket.py", line 47, in <module>
[Fri Dec 02 14:02:54.301128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] import _socket
[Fri Dec 02 14:02:54.301128 2016] [wsgi:error] [pid 10960:tid 752] [client ::1:54990] ImportError: DLL load failed: %1 \xed\xe5 \xff\xe2\xeb\xff\xe5\xf2\xf1\xff \xef\xf0\xe8\xeb\xee\xe6\xe5\xed\xe8\xe5\xec Win32.
I do not know what is wrong with that.
EDIT
This is what I have in settings.py:
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['localhost']
USE_X_FORWARDED_HOST = True
INTERNAL_IPS = ('127.0.0.1',)
EDIT
It seems like I tried dozens of virtual host configurations, but none of them works. This is the last configuration, that I tried:
Listen 8080
WSGIPythonPath C:/Apache242/htdocs/django
<VirtualHost *:8080>
DocumentRoot "C:/Apache242/htdocs/django"
ServerName localhost
WSGIScriptAlias / C:/Apache242/htdocs/django/accent/wsgi.py
<Directory C:/Apache242/htdocs/django/accent>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
LogLevel warn
</VirtualHost>
Apache restarts well, but when I go to localhost:8080, I still see the very same Internal Server Error. So, I guess my question now should be - does anybody use Apache with Django?
EDIT
Now I start to believe that it's all because of wsgi.py file. In my case it looks like:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "accent.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
But I do not know how to fix it. PS. I do not have virtual environment for Python, I just installed it globally.
You can try an htaccess file in root php directory, i'm not sure but you something like :
Options -Indexes
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/django(.*)$ http://127.0.0.1:8081$1 [L,QSA]

mod_authz_core denied : Laravel 5 + Apache 2.4 + Xampp: showing 403, using ElCapitan

I have a new Laravel 5 project on my Mac. Everything from github is set up and should work. It actually works on http://localhost:8000/ after running this command:
php artisan serv
But, i am seeing a 403 error when I type myprojectname.local in the browser when i want to use virtualhost.
I have several noframework projects in Php and they are still working fine, I can run them through my browser (Chrome) using otherproject.local Therefore I don't think VirtualHosts si the reason.
I am thinking about an authorization problem, so I checked the Owner and the group of my folder (/Users/username/Documents/foldername) but they are similar to the configuration in /private/etc/apache2/httpd.conf see bellow
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User username
Group staff
but there are so many "httpd.conf" in XAMPP and in private/etc etc... that I feel a bit lost.
On my errorlog (that i already set up in debug mode) here is what i see:
[Fri Aug 12 16:15:34.606324 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all denied: denied
[Fri Aug 12 16:15:34.606428 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: denied
[Fri Aug 12 16:15:34.606436 2016] [authz_core:error] [pid 40647] [client ::1:52290] AH01630: client denied by server configuration: /Users/username/Documents/foldername/public/
[Fri Aug 12 16:15:34.606527 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all granted: granted
[Fri Aug 12 16:15:34.606533 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: granted
[Fri Aug 12 16:15:34.606591 2016] [charset_lite:debug] [pid 40647] mod_charset_lite.c(219): [client ::1:52290] AH01448: incomplete configuration: src unspecified, dst unspecified
[Fri Aug 12 16:15:34.607115 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all granted: granted
[Fri Aug 12 16:15:34.607130 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: granted
[Fri Aug 12 16:15:34.607139 2016] [charset_lite:debug] [pid 40647] mod_charset_lite.c(219): [client ::1:52290] AH01448: incomplete configuration: src unspecified, dst unspecified
Finally found out:
The file that I needed to modify was located here:
/Applications/XAMPP/xamppfiles/etc/httpd.conf
What I needed to add inside this file was:
<Directory "/Users/username/Documents/foldername">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
Explanation:
The reason why I needed to insert the bloc above is: at the begining of httpd.conf, this part sets every folder as follows:
<Directory />
AllowOverride none
Require all denied
</Directory>
Which very probably causes Laravel to be denied from accessing the project folder
Now the error-log looks good:
[Tue Aug 16 14:47:12.326388 2016] [authz_core:debug] [pid 13960] mod_authz_core.c(809): [client ::1:52515] AH01626: authorization result of <RequireAny>: granted
Looking at it now, the difficult part was to fin the proper httpd.conf, among the numerous files named the same. I hope it will help

WAMP 403 forbidden from external sources

I have read a ton of threads here and elsewhere but none of the suggestions have worked. I installed the latest version of WAMP 64 bit on a fresh install of Windows Server 2012 R2.
I created a subdirectory within the www directory called andrew. In that is an index.html file.
I added the following to the hosts file:
127.0.0.1 andrew
::1 andrew
I added the following to the httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "c:/wamp64/www/andrew"
ServerName andrew
<Directory "c:/wamp64/www/andrew">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I uncommented the virtual hosts line in httpd.conf
I stopped and started net dnscache
I restarted the WAMP services
I "Put Online" the WAMP server
Regardless, when I access the server from another machine like [server IP address]*/andrew/index.html I get a 403 Forbidden error.
Here is the apache error log ("[SERVER IP]" is really the server's actual IP):
[Fri Apr 22 17:10:32.628356 2016] [mpm_winnt:notice] [pid 4680:tid 424] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Fri Apr 22 17:10:34.656507 2016] [mpm_winnt:notice] [pid 4444:tid 312] AH00364: Child: All worker threads have exited.
[Fri Apr 22 17:10:34.672087 2016] [mpm_winnt:notice] [pid 4680:tid 424] AH00430: Parent: Child process 4444 exited successfully.
[Fri Apr 22 17:10:34.921723 2016] [auth_digest:notice] [pid 4724:tid 416] AH01757: generating secret for digest authentication ...
[Fri Apr 22 17:10:34.952892 2016] [mpm_winnt:notice] [pid 4724:tid 416] AH00455: Apache/2.4.17 (Win64) PHP/5.6.16 configured -- resuming normal operations
[Fri Apr 22 17:10:34.952892 2016] [mpm_winnt:notice] [pid 4724:tid 416] AH00456: Apache Lounge VC14 Server built: Oct 11 2015 11:49:07
[Fri Apr 22 17:10:34.952892 2016] [core:notice] [pid 4724:tid 416] AH00094: Command line: 'C:\\wamp64\\bin\\apache\\apache2.4.17\\bin\\httpd.exe -d C:/wamp64/bin/apache/apache2.4.17'
[Fri Apr 22 17:10:34.952892 2016] [mpm_winnt:notice] [pid 4724:tid 416] AH00418: Parent: Created child process 4388
[Fri Apr 22 17:10:35.140157 2016] [auth_digest:notice] [pid 4388:tid 312] AH01757: generating secret for digest authentication ...
[Fri Apr 22 17:10:35.171357 2016] [mpm_winnt:notice] [pid 4388:tid 312] AH00354: Child: Starting 64 worker threads.
[Fri Apr 22 17:10:49.899265 2016] [authz_core:error] [pid 4388:tid 1040] [client 73.82.23.97:57193] AH01630: client denied by server configuration: C:/wamp64/www/andrew/index.html
[Fri Apr 22 17:10:50.055249 2016] [authz_core:error] [pid 4388:tid 1040] [client 73.82.23.97:57193] AH01630: client denied by server configuration: C:/wamp64/www/favicon.ico, referer: http://[SERVER IP]/andrew/index.html
I am now thinking it has to do with some setting on Windows 2012 Server, but I can't figure it out. Help.
Because Apache doesn't know to associate the IP address with your virtual host, it uses the main server settings. Probably you don't need a virtual host at all, but try this anyway:
<VirtualHost *:80>
DocumentRoot "c:/wamp64/www/andrew"
ServerName andrew
#of course, enter your IP address here
ServerAlias 1.2.3.4
<Directory "c:/wamp64/www/andrew">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
please don't forget to edit phpMyAdmin.conf file. It will save your time to face 403 Error (403 Forbidden). You should set Require all granted into it as follows (indipendently by used phpMyAdmin version):
Alias /phpmyadmin "c:/wamp64/apps/phpmyadmin5.0.2/"
<Directory "c:/wamp64/apps/phpmyadmin5.0.2/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted
# To import big file you can increase values
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</Directory>

Invalid command 'VirtualDocumentRoot'

I tried to configure my virtual PHP Devserver to use a part of the domain to serve different Directory's depending on the domain the request comes from... I guess that apache's missing the Virtual alias Module. I just can't figure out how i can check if it is there and if not how I can Install it... Below you'll find the site config file I was working on when I run a2dissite on it Apache Starts up just fine It's only when i enable vboxsf that it fails on startup/reload or whenever runs "configtest" on it's configuration...
Here is /etc/apache2/sites-available/vboxsf.conf
<VirtualHost *:80 *:8080>
ServerName sandbox
ServerAlias *.dev
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/dev-error.log
CustomLog ${APACHE_LOG_DIR}/dev-access.log combined
RewriteEngine On
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /media/>
Order allow,deny
Allow from all
Require all granted
</Directory>
<Location /server-status>
SetHandler server-status
Order allow,deny
Allow from all
Require all granted
</Location>
UseCanonicalName Off
VirtualDocumentRoot /media/sf_%1
</VirtualHost>
The output from sudo service apache2 reload
* Reloading web server apache2 *
* The apache2 configtest failed. Not doing anything.
Output of config test was:
AH00526: Syntax error on line 30 of /etc/apache2/sites-enabled/vboxsf.conf:
Invalid command 'VirtualDocumentRoot', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
And tail /var/log/apache2/error.log
[Wed Mar 04 17:05:43.698449 2015] [mpm_prefork:notice] [pid 1172] AH00169: caught SIGTERM, shutting down
[Wed Mar 04 17:28:35.880536 2015] [mpm_prefork:notice] [pid 2604] AH00163: Apache/2.4.10 (Ubuntu) PHP/5.5.12-2ubuntu4 configured -- resuming normal operations
[Wed Mar 04 17:28:35.880657 2015] [core:notice] [pid 2604] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 04 17:32:39.675812 2015] [mpm_prefork:notice] [pid 2604] AH00169: caught SIGTERM, shutting down
[Wed Mar 04 17:32:40.788348 2015] [mpm_prefork:notice] [pid 2715] AH00163: Apache/2.4.10 (Ubuntu) PHP/5.5.12-2ubuntu4 configured -- resuming normal operations
[Wed Mar 04 17:32:40.788487 2015] [core:notice] [pid 2715] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 04 17:32:58.596151 2015] [mpm_prefork:notice] [pid 2715] AH00169: caught SIGTERM, shutting down
[Wed Mar 04 17:32:59.706649 2015] [mpm_prefork:notice] [pid 2787] AH00163: Apache/2.4.10 (Ubuntu) PHP/5.5.12-2ubuntu4 configured -- resuming normal operations
[Wed Mar 04 17:32:59.706763 2015] [core:notice] [pid 2787] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 04 17:49:48.283025 2015] [mpm_prefork:notice] [pid 2787] AH00169: caught SIGTERM, shutting down
... or defined by a module not included in the server configuration
You are most likely missing the mod_vhost_alias plugin for apache.

Apache 2.4 + php-fpm - AH01071: Got error 'Primary script unknown\n' mod_proxy_balancer

I'm configuring an Apache 2.4.9 with php-fpm 5.5.9 in my Ubuntu 14.04. What I want is to make a balancer for the php-fpm requests but It throws the following error:
AH01071: Got error 'Primary script unknown\n'
When I try to access my php file. It seems that proxy balancer doesn't grab the document root passed by ProxyPassMatch to it. I'm using UDS to make apache access the php-fpm sockets instead of using network tcp.
If I configure it without balancer, everything works fine.
WORKS
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock1|fcgi://./var/www/html
NOT WORKS
ProxyPassMatch ^/(.*\.php(/.*)?)$ balancer://localhost/var/www/html
<Proxy balancer://localhost/>
BalancerMember unix:/var/run/php5-fpm.sock1|fcgi://localhost:9001
BalancerMember unix:/var/run/php5-fpm.sock2|fcgi://localhost:9002
BalancerMember unix:/var/run/php5-fpm.sock3|fcgi://localhost:9003
BalancerMember unix:/var/run/php5-fpm.sock4|fcgi://localhost:9004
</Proxy>
This is the balancer's config log:
[Sun Jun 15 12:32:30.839726 2014] [authz_core:debug] [pid 12217:tid 140330025703168] mod_authz_core.c(828): [client 10.1.1.2:52526] AH01628: authorization result: granted (no directives)
[Sun Jun 15 12:32:30.839899 2014] [lbmethod_byrequests:debug] [pid 12217:tid 140330025703168] mod_lbmethod_byrequests.c(97): AH01207: proxy: Entering byrequests for BALANCER (balancer://localhost)
[Sun Jun 15 12:32:30.839915 2014] [lbmethod_byrequests:debug] [pid 12217:tid 140330025703168] mod_lbmethod_byrequests.c(144): AH01208: proxy: byrequests selected worker "fcgi://localhost:9001" : busy 0 : lbstatus -3
[Sun Jun 15 12:32:30.839929 2014] [proxy_balancer:debug] [pid 12217:tid 140330025703168] mod_proxy_balancer.c(616): [client 10.1.1.2:52526] AH01172: balancer://localhost: worker (fcgi://localhost:9001) rewritten to fcgi://localhost:9001/var/www/html/info.php
[Sun Jun 15 12:32:30.839942 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(1761): AH00924: worker unix:/var/run/php5-fpm.sock1|fcgi://localhost:9001 shared already initialized
[Sun Jun 15 12:32:30.839958 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(1808): AH00927: initializing worker unix:/var/run/php5-fpm.sock1|fcgi://localhost:9001 local
[Sun Jun 15 12:32:30.840004 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(1843): AH00930: initialized pool in child 12217 for (localhost) min=0 max=25 smax=25
[Sun Jun 15 12:32:30.840018 2014] [proxy:debug] [pid 12217:tid 140330025703168] mod_proxy.c(1138): [client 10.1.1.2:52526] AH01143: Running scheme balancer handler (attempt 0)
[Sun Jun 15 12:32:30.840039 2014] [proxy_fcgi:debug] [pid 12217:tid 140330025703168] mod_proxy_fcgi.c(768): [client 10.1.1.2:52526] AH01076: url: fcgi://localhost:9001/var/www/html/info.php proxyname: (null) proxyport: 0
[Sun Jun 15 12:32:30.840058 2014] [proxy_fcgi:debug] [pid 12217:tid 140330025703168] mod_proxy_fcgi.c(775): [client 10.1.1.2:52526] AH01078: serving URL fcgi://localhost:9001/var/www/html/info.php
[Sun Jun 15 12:32:30.840090 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2094): AH00942: FCGI: has acquired connection for (localhost)
[Sun Jun 15 12:32:30.840102 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2108): AH02545: FCGI: has determined UDS as /var/run/php5-fpm.sock1
[Sun Jun 15 12:32:30.840115 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2169): [client 10.1.1.2:52526] AH00944: connecting fcgi://localhost:9001/var/www/html/info.php to localhost:9001
[Sun Jun 15 12:32:30.840134 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2304): [client 10.1.1.2:52526] AH00947: connected /var/www/html/info.php to localhost:9001
[Sun Jun 15 12:32:30.840272 2014] [authz_core:debug] [pid 12217:tid 140330025703168] mod_authz_core.c(828): [client 10.1.1.2:52526] AH01628: authorization result: granted (no directives)
[Sun Jun 15 12:32:30.842988 2014] [proxy_fcgi:error] [pid 12217:tid 140330025703168] [client 10.1.1.2:52526] AH01071: Got error 'Primary script unknown\n'
[Sun Jun 15 12:32:30.843095 2014] [proxy:debug] [pid 12217:tid 140330025703168] proxy_util.c(2132): AH00943: FCGI: has released connection for (localhost)
[Sun Jun 15 12:32:30.843134 2014] [proxy_balancer:debug] [pid 12217:tid 140330025703168] mod_proxy_balancer.c(670): [client 10.1.1.2:52526] AH01176: proxy_balancer_post_request for (balancer://localhost)
[Sun Jun 15 12:32:30.978315 2014] [authz_core:debug] [pid 12217:tid 140330017310464] mod_authz_core.c(802): [client 10.1.1.2:52526] AH01626: authorization result of Require all granted: granted
[Sun Jun 15 12:32:30.978346 2014] [authz_core:debug] [pid 12217:tid 140330017310464] mod_authz_core.c(802): [client 10.1.1.2:52526] AH01626: authorization result of <RequireAny>: granted
[Sun Jun 15 12:32:30.978387 2014] [core:info] [pid 12217:tid 140330017310464] [client 10.1.1.2:52526] AH00128: File does not exist: /var/www/html/favicon.ico
tcpdump can be helpful in this case.
tcpdump port 9001 -A | strings
It will show you where apache try to find your primary file

Categories