Cannot load modules/mod_proxy_wstunnel.so into server - websocket

Recently I need integrate a websocket server with apache2,and I find that apache2.4 has supported websocket with the module : mod_proxy_wstunnel.
http://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html
I compiled them by myself, but encountered a problem :
httpd: Syntax error on line 122 of /usr/local/apache2/conf/httpd.conf: Cannot load modules/mod_proxy_wstunnel.so into server: /usr/local/apache2/modules/mod_proxy_wstunnel.so: undefined symbol: ap_proxy_release_connection
environment info:
OS:centos 6.8
php:php-7.0.10
apache:httpd-2.4.23
My steps are:
Download source code.
php7 github.com/php/php-src/releases/tag/php-7.0.10
apache2.4 github.com/apache/httpd/releases/tag/2.4.23
Copy to my workspace and tar,say /home
shell> tar -xjf php-7.0.10.tar.bz2
shell> tar -xjf httpd-2.4.23.tar.bz2
Install gcc : yum install gcc
Compile apache
down apr:apr-1.5.2.tar.gz apr-util-1.5.4.tar.gz
copy to /httpd-2.4.23/srclib
tar -zvf apr-1.5.2.tar.gz tar -zvf apr-util-1.5.4.tar.gz
Modify the files name: apr-1.5.2 as apr apr-util-1.5.4 as apr-util
Install pcre
yum install pcre-devel
./configure --enable-so --enable-http --enable-proxy --enable-proxy-http --with-included-apr --enable-proxy-wstunnel
make && make install
set apache server ip:
shell> vi /usr/local/apache2/conf/httpd.conf
ServerName 127.0.0.1
Compile php
libxml2:yum install libxml2-devel
mkdir /usr/local/php7
./configure --prefix=/usr/local/php7 --with-mysqli --enable-mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-apxs2=/usr/local/apache2/bin/apxs
make && make install
cp -v ./php.ini-production /usr/local/php7/lib/php.ini
configure httpd.conf
shell> vi /usr/local/apache2/conf/httpd.conf
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
enalbe mod_proxy_wstunnel
shell> vi /usr/local/apache2/conf/httpd.conf
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
Above is my steps. Then I try to start my apache2 :
/usr/local/apache2/bin/apachectl start
Got the following errors:
httpd: Syntax error on line 122 of /usr/local/apache2/conf/httpd.conf: Cannot load modules/mod_proxy_wstunnel.so into server: /usr/local/apache2/modules/mod_proxy_wstunnel.so: undefined symbol: ap_proxy_release_connection
I have google it , but can't find some helpful info.

You need to load mod_proxy as well as mod_proxy_wstunnel. If you load an underlying proxy module (http/fcgi/ajp/wstunnel) without mod_proxy you will get this error.
So check your configuration and make sure you have a LoadModule directive for mod_proxy as well as mod_proxy_wstunnel.
You can also use the output of apachectl -M to check the modules Apache is loading.

Related

how to make ansible work on remote servers which has python 2.4

Making my question more meaningful...
Ansible controller server :
ansible 2.4.2.0
Python 2.7.5
Managed nodename (goldville):
Python 2.4.2
When i run #ansible goldville -m ping
I get the below error
File "/tmp/ansible_RSjze6/ansible_module_ping.py", line 8\r\n from future import absolute_import, division, print_function\r\nSyntaxError: future feature absolute_import is not defined\r\n"
How can i use this node with python 2.4.2 to run playbooks from controller.
[py24-hosts]
goldville-py3 ansible_host=goldville
[py23-hosts:vars]
ansible_python_interpreter=/usr/bin64/python2.4
When i run below it gave error
#ansible goldville -m ping
Failed to parse /home/ansible/ansiblehosts with ini plugin: /home/ansible/ansiblehosts:4: Section [py23-hosts:vars] not valid
for undefined group: py23-hosts
If you want use python 2.4 some hosts or groups, set the ansible_python_interpreter inventory variable, try something like this:
[py24-hosts]
goldville-py3 ansible_host=goldville
[py24-hosts:vars]
ansible_python_interpreter=/usr/bin64/python2.4
But if you want use python2.4 for all you must set interpreter_python key in the defaults section in the configuraion file ansible.cfg
Docuementation:
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

PHPCS cannot be set to PSR2 by default

I'm trying to set up PHPCS to run with PSR2 by default instead of having to specify it on each run.
I set the default with phpcs --config-set standard PSR2 When I check the configuration, it appears to be set:
$ phpcs --config-show
Using config file: /usr/bin/CodeSniffer.conf
standard: PSR2
When I actually run it on files, it runs as PEAR:
$ phpcs -v transarray.php
Registering sniffs in the PEAR standard... DONE (28 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /root
Processing transarray.php [PHP => 136 tokens in 26 lines]... DONE in 2ms (11 errors, 0 warnings)
...
If I run phpcs --standard=PSR2 ... it works correctly, but I would rather not have to include that every single time I run it.
The code errors reported match the standards in use.
According to the documentation you have to use default_standard as configuration key. So the command must be:
phpcs --config-set default_standard PSR2

Less Windows Node.js Hanging

I have been trying to setup Symfony2 on Windows so that I can use assetic with less.
I have installed node.js for Windows (0.6.8). Then I have run npm install less --global and found less in C:\Users\Matt\AppData\Roaming\npm\node_modules
As far as my Symfony setup, I have the master branch of Assetic (due to a bug I read about in 1.0.2), but the standard v1.0.1 of AsseticBundle
After some work, I was able to get an example less file to render via:
http://localhost/app_dev.php/css/compiled-main_part_1_boilerplate_1.css
Then I switched a .less file that #imports other .less files (in the same subdirectory). Whenever I try to go to that page on my local server (using this less configuration) it hangs and I can see a command process and a node.exe process both running.
The command is trying to run a script in node.js which exists in my temporary directory. I can run that file through node.js in a command prompt fine, but I cannot get it to load using Symfony/Assetic.
Is there anyway to use node.js, less, and assetic on Windows?
Here is my relevant config file sections:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [FeedStreamMainBundle]
# java: /usr/bin/java
filters:
cssrewrite: ~
less:
node: %assetic_node%
node_paths: [%assetic_less_path%]
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
yui_css:
jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar
# closure:
# jar: %kernel.root_dir%/java/compiler.jar
dev config override:
assetic:
use_controller: true
in parameters.ini:
assetic_node="C:\\Program Files (x86)\\nodejs\\node"
assetic_less_path="C:\\Users\\Matt\\AppData\\Roaming\\npm\\node_modules"
yes, use lessphp (server side)
Symfony2.1. How to integrate assetic lessphp filter. Add the following
package to your composer.json:
"require": {
...
"leafo/lessphp": "dev-master",
...
}
Run php composer.phar update
and update your config.yml
#...
assetic:
#...
filters:
lessphp:
file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
apply_to: "\.less$"
or use the less.js (client side)
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="less.js" type="text/javascript"></script>
I used the following and this works for me. NOTE that it is 'node.exe' and not just node.
node: "C:\\Program Files (x86)\\nodejs\\node.exe"
node_paths: ["C:\\Users\\Ben\AppData\\Roaming\\npm\\node_modules"]
apply_to: "\.less$"
Since no one really has any answers, I can only assume there are very few Windows developers using LESS and node.js in Symfony2.
My solution was to use lessphp which worked fine once I got it into the autoloader.

Apache2 doesn't execute .rb files (mod_ruby)

I want to make apache2 run ruby scripts. I managed to do this by using CGI, but now I want to go one step further and do it with mod_ruby. I installed mod_ruby through apt-get so it's supposed to be enabled, but when I visit http://localhost/test.rb my browser downloads the file instead of displaying it's output.
If I open /etc/apache2/mods-enabled/ruby.load there is a line containing the path do this mod.
I also added the following lined to my apache2.conf:
<IfModule mod_ruby.c>
<Directory /var/www/>
Options +ExecCGI
</Directory>
RubyRequire apache/ruby-run
#RubySafeLevel 0
<Files *.rb>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
</IfModule>
Can you please help me?
PS. Please don't suggest using ROR. I'm familiar with that. Now I just want to use ruby for educational reasons. Also please keep things simple I'm a total newbie to apache.
See this article - it has some instructions. Basically you need to tell Apache to pass your Ruby files through the handler.
Also, consider trying Sinatra - it's a micro web framework that's as simple as plain ruby files. And it runs with Passenger which is the well-documented Ruby module for Apache.
The article on HowtoForge covers almost the whole story, but I needed to add one line inside the <Directory /var/www> directive to prevent browsers from downloading the file:
AddType text/html .rb .rbx
Here are a couple more sites that I found helpful:
https://defuse.ca/blog/2012/07/how-to-install-mod_ruby-on-debian-squeeze/
http://modruby.net/en/doc/
Debian Stretch 9.
I tried installing mod_ruby with apt-get install libapache2-mod-ruby but there is no package by that name. In the end, all I needed to do was add this line to the apache-config to get the server to run my scripts.
AddHandler cgi-script .rb

Ruby on Apache with mod_ruby

I really want to run some ruby code on Apache server. I've got libapache2-mod-ruby and libapache-ruby1.8 installed (complete list of what is installed is here). What do I do now to make it run (here`s an example)?
Here's a quick howto to get mod_ruby up and running. A short summary of the steps I used on Ubuntu 12.04 is replicated here:
Install mod_ruby for apache:
sudo apt-get install libapache2-mod-ruby
To enable mod_ruby for all files under /var/www, edit your apache config file, i.e. /etc/apache2/sites-enabled/000-default
I had to add +ExecCGI to Options, and add the section pertaining to Ruby:
<Directory /var/www/>
Options Indexes +ExecCGI
# Ruby with mod_ruby
RubyRequire apache/ruby-run
<Files *.rb>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
AddType text/html rb
</Files>
</Directory>
The main drawback that I see is that I can't seem to find a way to set the mime/content type from within the script. You have to set it globally for all ruby scripts with the AddType text/html rb directive.
Finally, you need a test script in /var/www and it must be executable. For example, I have /var/www/test.rb:
#!/usr/bin/ruby
puts "Hello World!<br><pre>"
ENV.each { |k,v|
puts "#{k}=#{v}"
}
puts "</pre>"
Don't forget to make it executable:
chmod a+x /var/www/test.rb
And this outputs:
Hello World!
HTTP_HOST=10.0.1.3
HTTP_CONNECTION=keep-alive
HTTP_CACHE_CONTROL=max-age=0
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
HTTP_ACCEPT_ENCODING=gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE=en-US,en;q=0.8
HTTP_COOKIE=__test=1;
PATH=/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin
SERVER_SIGNATURE=
Apache/2.2.22 (Ubuntu) Server at 10.0.1.3 Port 80
SERVER_SOFTWARE=Apache/2.2.22 (Ubuntu)
SERVER_NAME=10.0.1.3
SERVER_ADDR=10.0.1.3
SERVER_PORT=80
REMOTE_ADDR=10.0.1.3
DOCUMENT_ROOT=/var/www
SERVER_ADMIN=webmaster#localhost
SCRIPT_FILENAME=/var/www/test.rb
REMOTE_PORT=38188
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=GET
REQUEST_URI=/test.rb
SCRIPT_NAME=/test.rb
MOD_RUBY=mod_ruby/1.2.6
GATEWAY_INTERFACE=CGI-Ruby/1.1
I've run an Apache benchmark on mod_ruby vs. simple Ruby as CGI (which spins up the Ruby interpreter every request) and mod_ruby was about 8X faster and on par with PHP performance.
mod-ruby is not really the preferred way to go in the ruby community.
The easiest way for you to start it to install passenger (trough gem) and configure apache to use it.
It is really easy to do,
you can follow the official tutorial here: http://www.modrails.com/install.html

Resources