This is my program:
#include "fcgi_stdio.h"
#include <stdlib.h>
int main(){
while (FCGI_Accept() >= 0){
FCGI_printf("Content-Type:text/html\r\n\r\n");
FCGI_printf("<h1>Test</h1>\n");
}
return 0;
}
These are the options I added to the apache config for the virtual host I'm working with:
SetHandler fastcgi-script
Options +ExecCGI
I also have the following line in the same apache config file:
LoadModule fastcgi_module modules/mod_fastcgi.so
I followed directions at FastCGI script can't find libfcgi.so.0 in Apache 2.4.6 and mod_fastcgi to compile my program.
If I execute the compiled program directly, I receive the familiar "segmentation fault" on screen. When I try executing it via the server at http://127.0.0.1/a.out, I get an internal server error and the following in the error_log:
[Tue Nov 17 00:48:10 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" started (pid 9331)
[Tue Nov 17 00:48:10 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" (pid 9331) terminated due to uncaught signal '11' (Segmentation fault)
[Tue Nov 17 00:48:15 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" restarted (pid 9333)
[Tue Nov 17 00:48:15 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" (pid 9333) terminated due to uncaught signal '11' (Segmentation fault)
[Tue Nov 17 00:48:20 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" restarted (pid 9334)
[Tue Nov 17 00:48:20 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" (pid 9334) terminated due to uncaught signal '11' (Segmentation fault)
[Tue Nov 17 00:48:25 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" restarted (pid 9335)
[Tue Nov 17 00:48:25 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" (pid 9335) terminated due to uncaught signal '11' (Segmentation fault)
[Tue Nov 17 00:48:25 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:26 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:29 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:32 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:35 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:38 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:41 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:44 2015] [error] [client 127.0.0.1] FastCGI: comm with (dynamic) server "/usr/local/apache2/virt1/a.out" aborted: (first read) idle timeout (30 sec)
[Tue Nov 17 00:48:44 2015] [error] [client 127.0.0.1] FastCGI: incomplete headers (0 bytes) received from server "/usr/local/apache2/virt1/a.out"
[Tue Nov 17 00:48:44 2015] [warn] FastCGI: (dynamic) server "/usr/local/apache2/virt1/a.out" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds
[Tue Nov 17 00:48:44 2015] [error] [client 127.0.0.1] (2)No such file or directory: FastCGI: stat() of "/usr/local/apache2/virt1/favicon.ico" failed
Its basically telling me that apache is attempting to start the program a few times but the program returns segmentation fault.
The result I was expecting was the word Test in bold in a web browser.
How do I fix my program to make it compatible with fast-cgi so that I can execute it via a web browser?
I don't want to resort to the slow CGI interface which is why I'm trying to use functions beginning with FCGI.
Related
The webapp is deployed on EC2 and following error is faced randomly once or twice a day making the webapp inaccessible for some period of time. It is automatically corrected after some time.
(2)No such file or directory: [client xxx.xx.xx.xxx:xxxxx] mod_wsgi (pid=xxxxx): Unable to connect to WSGI daemon process 'web2py' on '/var/run/apache2/wsgi.30303.0.1.sock'.
Application Stack
web2py
mod_wsgi
Apache2
The logs are different every time before the error:
[Thu Sep 28 06:25:01.528334 2017] [mpm_event:notice] [pid 30303:tid 140438078609280] AH00493: SIGUSR1 received. Doing graceful restart
[Thu Sep 28 06:25:02.318551 2017] [ssl:warn] [pid 30303:tid 140438078609280] AH01906: ip-172-31-0-91.eu-west-1.compute.internal:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu Sep 28 06:25:02.318574 2017] [ssl:warn] [pid 30303:tid 140438078609280] AH01909: ip-172-31-0-91.eu-west-1.compute.internal:443:0 server certificate does NOT include an ID which matches the server name
[Thu Sep 28 06:25:02.318664 2017] [wsgi:warn] [pid 30303:tid 140438078609280] mod_wsgi: Compiled for Python/2.7.11.
[Thu Sep 28 06:25:02.318669 2017] [wsgi:warn] [pid 30303:tid 140438078609280] mod_wsgi: Runtime using Python/2.7.12.
[Thu Sep 28 06:25:02.319205 2017] [mpm_event:notice] [pid 30303:tid 140438078609280] AH00489: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Thu Sep 28 06:25:02.319225 2017] [core:notice] [pid 30303:tid 140438078609280] AH00094: Command line: '/usr/sbin/apache2'
[Thu Sep 28 06:25:09.327495 2017] [mpm_event:error] [pid 30303:tid 140438078609280] AH00485: scoreboard is full, not at MaxRequestWorkers
[Thu Sep 28 06:28:39.560285 2017] [mpm_event:error] [pid 30303:tid 140438078609280] AH00485: scoreboard is full, not at MaxRequestWorkers
[Thu Sep 28 06:45:27.583870 2017] [wsgi:error] [pid 30307:tid 140437629064960] (2)No such file or directory: [client 172.31.32.163:24210] mod_wsgi (pid=30307): Unable to connect to WSGI daemon process 'web2py' on '/var/run/apache2/wsgi.30303.0.1.sock'.
[Thu Sep 28 06:49:14.503732 2017] [wsgi:error] [pid 30307:tid 140437603886848] (2)No such file or directory: [client 172.31.14.173:37726] mod_wsgi (pid=30307): Unable to connect to WSGI daemon process 'web2py' on '/var/run/apache2/wsgi.30303.0.1.sock'.
Let me know if more information is required.
This is caused by doing a graceful restart of Apache when HTTP clients are using keep alive connections and issuing multiple requests over the same connection.
The problem is that the way Apache manages the mod_wsgi daemon process means they are shutdown straight away still even if is a graceful restart. In the meantime, the Apache child worker processes which accept the requests initially and proxy to the mod_wsgi daemon processes will keep running until all client connections drop. This means that when have keep alive connections and subsequent request over same client connection needs to go to the WSGI application, that it will fail as the prior incarnation of the mod_wsgi daemon processes are now gone.
In this situation one can't allow the old Apache child worker process to connect to new mod_wsgi daemon processes as the reason for a restart may have been a configuration change and allowing old child worker process to connect to new instances of daemon processes, could introduce a security problem if under the new configuration the request being handled in that way was not allowed.
Do accept this is a rare scenario, and likelihood of a security issue arising is slim. It is probably reasonable to consider a new option to mod_wsgi to say that connecting to newer daemon process in this case is okay, and not rotate the listener socket for the daemon processes on any restart.
That this can occur has been known all along (10 years), but an issue for it has been created on GitHub against mod_wsgi to consider such an option.
https://github.com/GrahamDumpleton/mod_wsgi/issues/229
I have configured tomcat to run on port 80 with apache2 and mod_jk and this work well. If i reboot the system then the site will be the standart site from apache2. If i restart apache2 (/etc/init.d/apache2 restart) the site will come from tomcat. But why first after restart of apache2?
Anyone an idea?
Log after reboot the system (in /var/log/apache2/):
> mod_jk.log <
[Mon Sep 22 16:24:40.296 2014] [2256:3075069696] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Mon Sep 22 16:24:40.296 2014] [2256:3075069696] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-manager' in uri map post processing.
[Mon Sep 22 16:24:40.296 2014] [2256:3075069696] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-status' in uri map post processing.
[Mon Sep 22 16:24:40.298 2014] [2257:3075069696] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Mon Sep 22 16:24:40.298 2014] [2257:3075069696] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-manager' in uri map post processing.
[Mon Sep 22 16:24:40.298 2014] [2257:3075069696] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-status' in uri map post processing.
> error.log <
[Mon Sep 22 16:24:40 2014] [notice] Apache/2.2.22 (Debian) mod_jk/1.2.37 configured -- resuming normal operations
[Mon Sep 22 16:26:50 2014] [notice] caught SIGTERM, shutting down
Log after restart apache (in /var/log/apache2/):
> mod_jk.log <
[Mon Sep 22 16:29:10.042 2014] [3599:3074443008] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Mon Sep 22 16:29:10.042 2014] [3599:3074443008] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-manager' in uri map post processing.
[Mon Sep 22 16:29:10.042 2014] [3599:3074443008] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-status' in uri map post processing.
[Mon Sep 22 16:29:10.052 2014] [3600:3074443008] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Mon Sep 22 16:29:10.052 2014] [3600:3074443008] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-manager' in uri map post processing.
[Mon Sep 22 16:29:10.052 2014] [3600:3074443008] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-status' in uri map post processing.
> error.log <
[Mon Sep 22 16:29:10 2014] [notice] Apache/2.2.22 (Debian) mod_jk/1.2.37 configured -- resuming normal operations
EDIT 1:
Ok, i have tested this several times and find out that the apache2 / tomcat7 / mod_jk behavior is more crazy xD
I will show you my configurations:
> local: hosts <
192.168.84.129 migor
192.168.84.129 test.migor
> in tomcat server.xml <
<Host name="test.migor" appBase="myapps/test" unpackWARs="true" autoDeploy="true" />
> worker.properties <
workers.tomcat_home=/var/lib/tomcat7
workers.java_home=/usr/lib/jvm/java-7
ps=/
worker.list=ajp13_worker
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
worker.ajp13_worker.lbfactor=1
> sitea-available/test.migor <
<Virtualhost test.migor>
JkMount /* ajp13_worker
ServerName test.migor
DocumentRoot /var/lib/tomcat7/myapps/test
ErrorLog /var/lib/tomcat7/logs/error.log
CustomLog /var/lib/tomcat7/logs/access.log common
<Directory /var/lib/tomcat7/myapps/test>
Options -Indexes
</Directory>
</Virtualhost>
Now the behavior:
After reboot under url: "test.migor/", "migor/" and my server ip 192.168.84.129 i will get the site from apache2
After restarting apache2 i will get on migor/ and 192.168.84.129 the tomcat page from webapps and on test.migor/ the page from myapps/test. Here the problem, i expected on 192.168.84.129 the page from apache2.
Any an idea?
EDIT 2:
Ok, i have forget to add "NameVirtualHost test.migor" to "sitea-available/test.migor" and my config have completly overwrite default settiong of apache. Now is the behavior ok for me. With url "migor/" i can call default apache site and with url "test.migor/" i can call the tomcat homepage which is in tomcat7/myapps/test.
But this behavior will be activated only after restart of apache2 (if i have rebooted my system before). I will show for the solution and post it here. Maybe in "EDIT 3" xD
The error clearly says that jk-manager and jk-status is not accurately defined in workers.property file.
Please check your workers.properties file and make following changes:
worker.list=jk-manager
worker.jk-manager.type=status
worker.list=jk-status
worker.jk-status.type=status
worker.jk-status.read_only=true
Cheers!!
I've installed mod_pagespeed with the config included below. While it works well, I am getting a lot of output in my /var/log/apache2/error.log file that I'm not sure how to resolve.
Config
ModPagespeed on
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedFileCachePath "/var/mod_pagespeed/cache/"
ModPagespeedEnableFilters combine_css,rewrite_css,inline_css
ModPagespeedEnableFilters combine_javascript,rewrite_javascript,inline_javascript
ModPagespeedEnableFilters extend_cache
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters collapse_whitespace
ModPagespeedEnableFilters remove_comments
ModPagespeedEnableFilters elide_attributes
ModPagespeedRateLimitBackgroundFetches on
Errors
[Fri Jun 28 13:29:15 2013] [error] [mod_pagespeed 1.4.26.3-3101 #31464] Serf status 120105(APR does not understand this error code) polling for 30 threaded fetches for 0.05 seconds
[Fri Jun 28 13:29:15 2013] [error] [mod_pagespeed 1.4.26.3-3101 #31464] Serf status 120105(APR does not understand this error code) polling for 30 threaded fetches for 0.05 seconds
[Fri Jun 28 13:29:15 2013] [error] [mod_pagespeed 1.4.26.3-3101 #31464] Serf status 120105(APR does not understand this error code) polling for 30 threaded fetches for 0.05 seconds
[Fri Jun 28 13:29:15 2013] [warn] [mod_pagespeed 1.4.26.3-3101 #31464] Fetch timed out: http://IP_ADDRESS:443/img/icon/arrow-right-5x8.png (30) waiting for 50 ms
[Fri Jun 28 13:29:15 2013] [warn] [mod_pagespeed 1.4.26.3-3101 #31464] Fetch timed out: http://IP_ADDRESS:443/img/layout/navbar-divider.png (29) waiting for 50 ms
[Fri Jun 28 13:29:15 2013] [warn] [mod_pagespeed 1.4.26.3-3101 #31464] Fetch timed out: http://IP_ADDRESS:443/img/layout/navbar-label.png (28) waiting for 50 ms
[Fri Jun 28 13:29:15 2013] [warn] [mod_pagespeed 1.4.26.3-3101 #31464] Fetch timed out: http://IP_ADDRESS:443/img/layout/portal-icon.png (27) waiting for 50 ms
By default, mod_pagespeed will fetch css/js/images using http. If the webserver doesn't respond within 50ms (by default), it will abort the request, and log the timeout messages you are seeing.
However, there seems to be another problem: Serf status 120105 indicates a bad response was received. You might want to investigate the apache logs, maybe you can find a clue about what is going on. I don't think those messages are related to mod_pagespeed, it is just the messenger in this case.
To get rid of these messages, I suggest you configure pagespeed to load files from disk instead[1] using ModPagespeedLoadFromFile and friends, which will resolve these messages, and brings these other benefits:
It will probably be a lot faster
It consumes less webserver resources by avoiding loopback requests
Changes to css/js/images will be processed immediately
[1] https://developers.google.com/speed/pagespeed/module/domains
I am trying to configure php 5.4.9 with apache 2.4 but when i include the lines below apache won't start.
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php"
I've checked all my file paths and they are all ok. I have the path set in environment to C:\php;c:\Apache24;c:\Apache24\bin;.
The error I'm actually getting is
Windows could not start the Apache2.4 on local computer. For more information, review the system eventlog. If this is a non-microsoft service, contact the service vendor, and refer to service-specific error code 1
Anybody else ever have this issue?
UPDATE
I do have php5apache2_4.dll in the php folder and my error logs in apache
[Sun Dec 09 11:19:16.502272 2012] [mpm_winnt:notice] [pid 5552:tid 316] AH00418: Parent: Created child process 5052
[Sun Dec 09 11:19:18.315156 2012] [mpm_winnt:notice] [pid 5052:tid 208] AH00354: Child: Starting 64 worker threads.
[Sun Dec 09 11:29:53.861913 2012] [mpm_winnt:notice] [pid 5552:tid 316] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Dec 09 11:29:55.889916 2012] [mpm_winnt:notice] [pid 5052:tid 208] AH00364: Child: All worker threads have exited.
[Sun Dec 09 11:29:55.905516 2012] [mpm_winnt:notice] [pid 5552:tid 316] AH00430: Parent: Child process exited successfully.
I use a Glassfish-ApplicationServer for a Webapplication. The Glassfish is connected with mod_jk to a Apache2-Server.
Now there is a really strange behavior: Some Parts of the received Files (html, css, js, ...) are missing and there are strange numbers in the Files... If I use the direct access to the Glassfish eth works.
I use Glassfish 3.1.2, mod_jk 1.2.33 and Apache2. The Webapplication uses jsf/Primefaces 3.2.
In the mod_jk log there are strange error Messages. The Messages apear only on the first access to the Webpage.
[Mon Mar 19 13:33:42 2012] [3763:2928831344] [error]ajp_connection_tcp_get_message::jk_ajp_common.c (1280): wrong message format 0x2020 from 127.0.0.1:9009
[Mon Mar 19 13:33:42 2012] [3763:2928831344] [error] ajp_get_reply::jk_ajp_common.c (2145): (ajp13_worker) Tomcat is down or network problems. Part of the response has already been sent to the client
[Mon Mar 19 13:33:42 2012] [3763:2928831344] [info] ajp_service::jk_ajp_common.c (2614): (ajp13_worker) sending request to tomcat failed (recoverable), because of protocol error (attempt=2)
[Mon Mar 19 13:33:42 2012] [3763:2928831344] [error] ajp_service::jk_ajp_common.c (2634): (ajp13_worker) connecting to tomcat failed.
[Mon Mar 19 13:33:42 2012] [3763:2928831344] [info] jk_handler::mod_jk.c (2788): Service error=-11 for worker=ajp13_worker
[Mon Mar 19 13:33:42 2012] ajp13_worker ores.pragma.biz 0.191397
[Mon Mar 19 13:33:42 2012] [3764:2903653232] [error] ajp_connection_tcp_get_message::jk_ajp_common.c (1280): wrong message format 0x6973 from 127.0.0.1:9009
[Mon Mar 19 13:33:42 2012] [3764:2903653232] [error] ajp_get_reply::jk_ajp_common.c (2145): (ajp13_worker) Tomcat is down or network problems. Part of the response has already been sent to the client
[Mon Mar 19 13:33:42 2012] [3764:2903653232] [info] ajp_service::jk_ajp_common.c (2614): (ajp13_worker) sending request to tomcat failed (recoverable), because of protocol error (attempt=2)
[Mon Mar 19 13:33:42 2012] [3764:2903653232] [error] ajp_service::jk_ajp_common.c (2634): (ajp13_worker) connecting to tomcat failed.
[Mon Mar 19 13:33:42 2012] [3764:2903653232] [info] jk_handler::mod_jk.c (2788): Service error=-11 for worker=ajp13_worker
Hope, that anybody can help me.
Try installing GF 3.1.1 and see if that fixes the problem. I read about this bug last week, which might be your problem: http://java.net/jira/browse/GLASSFISH-18446 Looks like there is a patch available on that bug.
This is not exactly an answer, but if by any chance you're using apache and mod_jk only as a proxy to GF (as we did for years) - install nginx, and forget about apache. It's like day and night.
http://wiki.nginx.org/HttpProxyModule