what is the difference between
mod_rewrite.so and mod_rewrite.c in Apache server ? In .htaccess file also we should write mod_rewrite.so or mod_rewrite.c ?
In Apache 2.x, it's normal to just use the .so. For example:
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
In Apache 1.x it was necessary to AddModule module.c after loading the shared library .so.
Related
I have this configuration:
Ubuntu Server 14.04
Apache 2.4.7 with proxy_module
PHP 5.5.9 + PHP5-FPM
I am passing all request for PHP files, with the php file extension, to the PHP wrapper through FastCGI with the following command:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
Now the problem is that when I am accessing the server with the following URL http://127.0.0.1/~myuser/phpinfo.php I receive File not found
If I am accessing it like this http://127.0.0.1/phpinfo.php it's working.
My question is how can I get rid of File not found error when I want to access the url with the user in it?
You have to add following lines to your httpd configuration
ProxyPassMatch ^/~myuser/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/myuser/public_html/$1
Premise:
I have a custom webserver running on port 2480. I don't really know how it works, but it has it's own www dir. Inside this dir, there is an index.htm file which is executed by default. Inside that file, there is
<meta http-equiv="refresh" content="0;URL=/studio/index.html">
So, I immediately get redirection to 107.0.0.1:2480/studio/index.html. However, I can't find such "studio" folder anywhere in my filesystem (I have no idea how this works).
Question:
In the same server, I have an Apache webserver running on port 80. I'd like to configure a reverse proxy so that "127.0.0.1:80/foo" is equal to "127.0.0.1:2480".
I did in apache2.conf:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
ProxyPass /foo http://localhost:2480/
ProxyPassReverse /foo http://localhost:2480/
Then, I navigate to "127.0.0.1:80/foo". I see that it correctly connects to "127.0.0.1:2480/index.htm". But then, index.htm immediately redirects to "/studio/index.html", and I see the url changes to "127.0.0.1:80/studio/index.html. I get then "403 forbidden". But this is a "fake forbidden", because doing this it is just looking for "/studio/index.html" in the default apache document root dir, which of course does not exists (and htaccess is configured to deny all by default).
So question is:
"127.0.0.1:80/foo" resolves correctly to "127.0.0.1:2480/index.htm"
"index.htm" redirects to "/studio/index.html"
why is apache looking for "127.0.0.1:80/studio/index.html" instead of "127.0.0.1:2480/studio/index.html" ?
How should this be done?
Thanks a lot
I am not able to configure the apache load balancer with mod_jk. Each time I channge httpd.conf file apache server doesnot start.
Here is the scenario:
I have 2 apache tomcat instance, Tomcat and tomcat2 and both are running on different ports.
I would like to establish a load balancer for these two instances with apache mod_jk:
I have downloded mod_jk.so file and places in modules folder.
Below configuration I am trying to httpd.conf file:
LoadModule jk_module modules/mod_jk.so
AddModule mod_jk.c
JkWorkersFile conf/workers.properties
JkLogFile log/httpd/mod_jk.log
JkLogLevel info
mod_jk loadbalancer
JkMount /examples/* loadbalancer
Here is my workers.propertise file:
# Define list of workers that will be used
worker.list=loadbalancer
# Define Node1
worker.node1.port=8009
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=10
# Define Node2
worker.node2.port=8010
worker.node2.host=localhost
worker.node2.type=ajp13
worker.node2.lbfactor=1
worker.node2.cachesize=10
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
# Status worker for managing load balancer
worker.status.type=status
I am not sure, what is wrong here. May be I am adding the mod_jk conf in httpd.conf file at wrong place.
Can anybody guide. Any sample working HTTPD.CONF file will be great.
Thanks you for the help.
-Santosh
Issue resolve:
I was using the mod_jk.so file compatible with apache version 2.0 and Apache webserver 2.2.
I have downloaded the mod_jk.so file compatible for 2.2 version and now everything is working fine.
You can check detailed error by option:
c:/your_apache_dir/bin> httpd.exe -D mod_jk
Thanks for your help.
JkWorkersFile "conf/workers.properties" this should be this way and also do check for the mod_jk compatibility.
Is there some apache server software out there that can be installed on my Windows PC (for local development purposes) that also allows .htaccess for URL rewriting?
I'm currently using Xampp which does not seem to offer this functionality (although maybe I'm wrong about that).
Any advice would be much appreciated.
Thanks.
You will have to activate mod_rewrite in your apache config. Go to your xampp folder an you will find the httpd.conf file in apache/conf/. Open it an go to the line with:
#LoadModule rewrite_module modules/mod_rewrite.so
Change it to
LoadModule rewrite_module modules/mod_rewrite.so
Save the httpd.conf and restart your apache. Now mod_rewrite should work.
Xampp will do it, you'll need to enable mod_rewrite first.
open the directory you installed Xampp then open \apache\conf\httpd.conf in notepad and search for mod_rewrite.
Uncomment the line by removing the # from the beginning. By default mod_rewrite is disabled on a fresh install.
LoadModule rewrite_module modules/mod_rewrite.so
Restart Xamppp should take .htaccess rules now.
It's true that by default, Xampp on windows does not support URL rewriting.
However it's an pretty easy fix:
In your httpd.conf file, find the line that contains "mod_rewrite" and remove the # in front of it
Again in your httpd.conf file, find all occurrences of AllowOverride None and change it to AllowOverride All
Restart apache and you're done:)
Mac OS X ships with apache pre-installed, but the files are in non-standard locations. This question is a place to collect information about where configuration files live, and how to tweak the apache installation to do things like serve php pages.
Apache Config file is: /private/etc/apache2/httpd.conf
Default DocumentRoot is: /Library/Webserver/Documents/
To enable PHP, at around line 114 (maybe) in the /private/etc/apache2/httpd.conf file is the following line:
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the pound sign to uncomment the line so now it looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
Restart Apache: System Preferences -> Sharing -> Un-check "Web Sharing" and re-check it.
OR
$ sudo apachectl restart
Running
$ httpd -V
will show you lots of useful server information, including where the httpd.conf file can be found.
To get SSI/includes (mod_include) to work I found I had to edit /private/etc/apache2/users/myusername.conf and change AllowOverride None to AllowOverride All.
Then add the following in a .htaccess file in the root of your site:
Options +Includes
AddType text/html .html
AddOutputFilter INCLUDES .html
httpd.conf is in /private/etc/apache2
Enable PHP by uncommenting line:
LoadModule php5_module libexec/apache2/libphp5.so
/etc/httpd/users contains user-specific configuration files which can be used to override the global configuration. For example, adding "AddHandler server-parsed html" to the <Directory> block in the /etc/httpd/users/*.conf file that corresponds to one user will enable mod_include parsing of HTML files for that particular user's $HOME/Sites directory, but nowhere else.