EzDevInfo.com

apache interview questions

Top apache frequently asked interview questions

How to check if mod_rewrite is enabled in php?

I was wondering if it is possible to check if mod_rewrite is enabled on Apache AND IIS in PHP.

ModRewrite for IIS exists. Check it here.

So, I'm looking for a PHP script that checks for mod_rewrite on Apache and IIS.

Does anyone know such script or can write one?

Especially for Microsoft IIS.

Thanks!


Source: (StackOverflow)

Difference between the Apache HTTP Server and Apache Tomcat? [closed]

What is the difference in terms of functionality between the Apache HTTP Server and Apache Tomcat?

I know that Tomcat is written in Java and the HTTP Server is in C, but other than that I do not really know how they are distinguished. Do they have different functionality?


Source: (StackOverflow)

Advertisements

UTF-8 all the way through

I'm setting up a new server, and want to support UTF-8 fully in my web application. I have tried in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.

Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL and PHP to do this - is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur?

This is for a new Linux server, running MySQL 5, PHP 5 and Apache 2.


Source: (StackOverflow)

HTTP_HOST vs. SERVER_NAME

When would you consider using one over the other and why?


Source: (StackOverflow)

Generic htaccess redirect www to non-www

I would like to redirect www.example.com to example.com. The following htaccess code makes this happen:

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

But, is there a way to do this in a generic fashion without hardcoding the domain name?


Source: (StackOverflow)

Ruby on Rails Server options [closed]

The whole issue of setting up a development server for my Ruby on Rails application confuses me. There are WEBrick, Mongrel, Passenger, Apache, Nginx and many more I am sure, and I don't really understand the different roles they play.

I started off using WEBrick, and now I use Mongrel for development. Are these servers stand-alone, or do they sit in front of Apache?

I have read about Passenger and I don't really understand what it is, the site says "makes deployment of Ruby web applications a breeze", does it replace Mongrel? Is it like Capistrano, which also deploys web applications?

Bearing in mind I would like to test SSL, and I believe that's not supported by mongrel, what is the best development server setup?


Source: (StackOverflow)

Wildcards in a Windows hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost. The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local, site2.local etc, and have them all resolve to localhost, while Apache serves a different site accordingly.

I am on Windows XP.

I tried adding

127.0.0.1       *.local

to my c:\windows\system32\drivers\etc\hosts file, also tried:

127.0.0.1       .local

Neither of which seem to work.

I know I can set them up on different port numbers, but that is a pain since it is hard to remember which port is which.

I don't want to have to setup a local DNS server or anything hard, any suggestions?


Source: (StackOverflow)

Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

I've got a XAMPP installation running on Windows 7.

As soon as I add a VirtualHost to httpd-vhosts.conf, BOTH the 'regular' http://localhost AND the new dropbox.local aren't working.

This is what I added to my httpd-vhosts.conf:

<VirtualHost *:80>
    ServerAdmin postmaster@dummy-host.localhost
    DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
    ServerName dropbox.local
    ServerAlias www.dropbox.local
    ErrorLog "logs/dropbox.local-error.log"
    CustomLog "logs/dropbox.local-access.log" combined
</VirtualHost>

So I looked up my dropbox.local-error.log for any information:

[Thu Feb 02 10:41:57 2012] [error] [client 127.0.0.1] client denied by server configuration: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

This error seems to be solved by adding

<directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
     Allow from all
</directory>

But now I get this error in dropbox.local-error.log:

[Thu Feb 02 10:45:56 2012] [error] [client ::1] Directory index forbidden by Options directive: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

Furthermore when I try to access http://localhost, I dont get any error in the regular error.log, although I get the error 403 when I try to access it.

Can anybody help... It's driving me mad :S

EDIT: Also in httpd.conf there is the following (I've seen it mentioned multiple times, so before anyone says it):

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

Source: (StackOverflow)

How to prevent browser page caching in Rails

Ubuntu -> Apache -> Phusion Passenger -> Rails 2.3

The main part of my site reacts to your clicks. So, if you click on a link, it will send you on to the destination, and instantly regenerate your page.

But, if you hit the back button, you don't see the new page. Unfortunately, it's not showing up without a manual refresh; it appears the browser is caching it. I want to make sure the browser does not cache the page.

Separately, I do want to set far-future expiration dates for all my static assets.

What's the best way to solve this? Should I solve this in Rails? Apache? Javascript?

Thanks for all your help, Jason


Alas. Neither of these suggestions forced the behavior I'm looking for.

Maybe there's a javascript answer? I could have rails write out a timestamp in a comment, then have the javascript check to see if the times are within five seconds (or whatever works). If yes, then fine, but if no, then reload the page?

Do you think this would work?

Thanks for all your help,

Jason


Source: (StackOverflow)

How can I install Apache Ant on Mac OS X?

I tried to install Apache Ant on my Mac and I followed the next steps :

  1. I downloaded apache-ant-1.8.1-bin.tar.gz into my Downloads folder.
  2. I moved the file to /usr/local/ using this commands : sudo sh and mv apache-ant-1.8.1-bin.tar.gz /usr/local/

Now I want to use cd /usr/local/ but it's not working, I get back "No such file or directory".

Then I used cd /usr/ and ls commands and it seems that the local folder is there. If I try to access it I get the same error.

Since I already used sudo su why I can't access it? Any ideas?


Source: (StackOverflow)

PHP Fatal error: Call to undefined function json_decode()

Apache is logging PHP Fatal error: Call to undefined function json_decode(). After some googling, it seems this problem is a result of not having the latest version of php. Oddly, running php --version ouputs

PHP 5.5.1-2+debphp.org~precise+2 (cli) (built: Aug  6 2013 10:49:43) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.2-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Clearly showing that my php version is greater than 5.1.

Any ideas as to what could cause this, or the steps to take to find out?

EDIT: The result of a script echoing phpversion is 5.5.1-2+debphp.org~precise

EDIT: The result of phpinfo() is also PHP Version 5.5.1-2+debphp.org~precise+2

Furthermore, in the phpinfo(), it lists the module JSON and the module authors (Omar Kilani, Scott MacVicar).


Source: (StackOverflow)

How Python web frameworks, WSGI and CGI fit together

I have a Bluehost account where I can run Python scripts as CGI. I guess it's the simplest CGI, because to run I have to define the following in .htaccess:

Options +ExecCGI
AddType text/html py
AddHandler cgi-script .py

Now, whenever I look up web programming with Python, I hear a lot about WSGI and how most frameworks use it. But I just don't understand how it all fits together, especially when my web server is given (Apache running at a host's machine) and not something I can really play with (except defining .htaccess commands).

How are WSGI, CGI, and the frameworks all connected? What do I need to know, install, and do if I want to run a web framework (say web.py or CherryPy) on my basic CGI configuration? How to install WSGI support?


Source: (StackOverflow)

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

CentOS 5.0

I tried to restart my apache server and got this messeage

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

here is /etc/host file

127.0.0.1   server4-245 server4-245.com localhost.localdomain localhost
::1     localhost6.localdomain6 localhost6

here is /etc/sysconfig/network file

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server4-245

I also have this in apache httpd.conf file

ServerName localhost

However, I still get the first error messeage when I restart the apache.


Source: (StackOverflow)

apache redirect from non www to www

I have a mortgage calculator site that doesn't seem to redirect from mookal.com to www.mookal.com
My apache config is as follows:

RewriteEngine On
### re-direct to www
RewriteCond %{http_host} !^www.mookal.com [nc]
RewriteRule ^(.*)$ http://www.mookal.com/$1 [r=301,nc] 

What am I missing?


Source: (StackOverflow)

Hidden features of mod_rewrite

There seem to be a decent number of mod_rewrite threads floating around lately with a bit of confusion over how certain aspects of it work. As a result I've compiled a few notes on common functionality, and perhaps a few annoying nuances.

What other features / common issues have you run across using mod_rewrite?


Source: (StackOverflow)