You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Frederick Miller <fj...@gmail.com> on 2013/12/24 23:55:32 UTC

[users@httpd] Need an example of how to use Apache Server 2.2.

I need an example of a simple application and how to set it up on Apache
2.2.  I'm running Windows XP, and I've read all the documentation.  I've
put some Web apps under the htdocs folder, but they just show the source
html and don't actually run the application.  I'd like to see an example
that is more than just HTML, what folder to copy it into, and what the
expected output is.  I've done JSPs and Servlets with Tomcat, but I'm new
to Apache Server 2.2.  Thanks.

Frederick Miller

[users@httpd] Re: Need an example of how to use Apache Server 2.2.

Posted by Mark Eggers <md...@gmail.com>.
On Tue, 24 Dec 2013 17:55:32 -0500, Frederick Miller wrote:

> I need an example of a simple application and how to set it up on Apache
> 2.2.  I'm running Windows XP, and I've read all the documentation.  I've
> put some Web apps under the htdocs folder, but they just show the source
> html and don't actually run the application.  I'd like to see an example
> that is more than just HTML, what folder to copy it into, and what the
> expected output is.  I've done JSPs and Servlets with Tomcat, but I'm
> new to Apache Server 2.2.  Thanks.

This is going to be long. For those of you used to reading my comments on 
the Apache Tomcat mailing list, you know what you're about to be hit with.

For others, it's best to press "next" now :-p.

This is a thumbnail sketch on how to get going.

First of all, in your original mail message you didn't say what type of 
web application you wanted to build. Unlike Tomcat, Apache HTTPD doesn't 
really run applications by itself. It uses modules to enable creation of 
dynamic content. Some of these modules are:

mod_cgi - Generic CGI module
mod_perl - Perl module
mod_php - PHP module
mod_fcgid - Fast CGI module

There are a bunch of others (Python, Scheme, etc.), but the above are the 
major ones.

To get mod_cgi to work, you just follow the directions at:

http://localhost/manual/howto/cgi.html

which you said you've read, so I won't rehash the documentation.

Obviously, in order to get Perl scripts to run, you'll need to install 
Perl. ActiveState Perl makes a nice Windows version.

CGI is a rather slow way to execute scripts, since Apache HTTPD has to 
start up an interpreter for each request. A better way to do this is to 
run either a targeted module (mod_perl, mod_php), or mod_fcgid (fast cgi) 
which starts up several copies of an interpreter and keeps them running to 
manage requests.

mod_fcgid is available as a binary from Apache. I've not used it on 
Windows/XP, so read the documentation (which you've said you've done).

mod_perl may or may not be up to date, and the dependencies may or may not 
be available. The last time I attempted to install mod_perl on Apache 
2.2.x and Windows/XP, the dependencies were not available, and the 
installation failed. This may have changed.

mod_php is probably the easiest to implement. I'll outline the 
installation below, since you've already read all of the documentation.

1. Install Apache HTTPD 2.2.x
   a. Use a directory without spaces
   b. Make sure you can run this as a service before doing anything else
   c. Drop in some HTML and CSS, to make sure Apache HTTPD serves this up
   d. Don't forget to allow port 80 in the firewall if you want to 
      remotely access your web server
2. Install PHP
   a. Use a directory without spaces
   b. Install PEAR
      http://pear.php.net/manual/en/installation.getting.php
   c. Install PECL extensions if needed
      http://windows.php.net/downloads/pecl/releases/
   d. Edit php.ini
      1. enable extensions
      2. set time zone
      3. set latitude and longitude
      4. php.ini has copious comments
3. Edit httpd.conf to include PHP
   a. add module - for example:
      LoadModule php5_module "C:/PHP/php5apache2_2.dll"
   b. Tell Apache HTTPD what constitutes PHP files - for example:
      AddHandler application/x-httpd-php .php
      AddHandler application/x-httpd-source .phps
   c. Tell PHP where it can find the php.ini file - for example:
      PHPIniDir "C:/PHP"
4. Restart Apache HTTPD

Now to test, create the following simple PHP file and call it info.php.

<?php print phpinfo(); ?>

Browse to http://localhost/info.php and see what it says.

Lather, rinse, repeat.

Now you should be able to write and run PHP applications. I like using 
NetBeans as an IDE - your tastes may differ.

If you've noticed, I've been a bit sarcastic from time to time when 
answering your question. For that I apologize. However, there are good 
reasons for why you've not received a reasonable answer to your question.

1. You didn't clearly state what you wanted to accomplish
2. You stated that you've read "all" of the documentation

If you had said something like:

"I want to run dynamically generated content from an Apache HTTPD server. 
I am familiar with Tomcat, servlets, and JSP. I would like to do similar 
things using Apache HTTPD. What languages and setup are recommended?" 

Someone would probably have pointed you to PHP and one of many blog posts 
on getting PHP and Apache HTTPD running on Windows/XP. In addition, you 
could have started a mini flame war if people started suggesting MVC 
frameworks - eh, but that's programming in general.

All of the answers that I've outlined above are readily available from 
existing documentation as well as by searching the HTTPD mailing list 
archives. Stating you have read "all" of the documentation while asking 
such poorly a defined question indicates a lot of things, none of which 
are good.

Hopefully, this will get you started.

Also, read the following:

http://www.catb.org/~esr/faqs/smart-questions.html

We're all just volunteers, trying to give a little back to the community. 
Make it easier to volunteer.

. . . . just my two cents
/mde/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Need an example of how to use Apache Server 2.2.

Posted by Frederick Miller <fj...@gmail.com>.
Thanks.  I'm going to try mod_php.


On Tue, Dec 24, 2013 at 8:53 PM, Yehuda Katz <ye...@ymkatz.net> wrote:

> If you put HTML files in the htdocs folder, Apache should serve them as
> HTML and then it depends on your browser understanding the HTML properly.
> In most browsers, there is a development or debug panel that let's you see
> the raw request and response. If you are not sure how to get that or what
> the proper response values are, post specific examples (and what browser
> you are using).
> If you want to put anything more complicated than static content, you need
> to use the appropriate Apache module (for example mod_php will run PHP
> code) or CGI configuration.
>
> You should also check that your code if properly formatted - specifically
> that you have < and > and not &lt; and &gt;
>
> Sent from a gizmo with a very small keyboard and hyperactive autocorrect.
> On Dec 24, 2013 5:56 PM, "Frederick Miller" <fj...@gmail.com> wrote:
>
>> I need an example of a simple application and how to set it up on Apache
>> 2.2.  I'm running Windows XP, and I've read all the documentation.  I've
>> put some Web apps under the htdocs folder, but they just show the source
>> html and don't actually run the application.  I'd like to see an example
>> that is more than just HTML, what folder to copy it into, and what the
>> expected output is.  I've done JSPs and Servlets with Tomcat, but I'm new
>> to Apache Server 2.2.  Thanks.
>>
>> Frederick Miller
>>
>

Re: [users@httpd] Need an example of how to use Apache Server 2.2.

Posted by Yehuda Katz <ye...@ymkatz.net>.
On Thu, Dec 26, 2013 at 6:25 PM, Frederick Miller <fj...@gmail.com>wrote:

> i am trying to unsubscribe, but I send to:
> *users-unsubscribe@httpd.apache.org <us...@httpd.apache.org> **and
> it comes back as permanently undeliverable*
>

I just tested and the unsubscribe address is working properly. What is the
full error you get?


> *I'm getting tons of emails, and I haven't gotten any real help.*
>

You haven't gotten any "real help" because you haven't asked any "real
questions".

Re: [users@httpd] Need an example of how to use Apache Server 2.2.

Posted by Frederick Miller <fj...@gmail.com>.
i am trying to unsubscribe, but I send to:

*users-unsubscribe@httpd.apache.org <us...@httpd.apache.org>*


*and it comes back as permanently undeliverable*
*I'm getting tons of emails, and I haven't gotten any real help.  how can i
unsubscribe.  the email address, *
*users-unsubscribe@httpd.apache.org <us...@httpd.apache.org>
comes back as undeliverable.*


On Tue, Dec 24, 2013 at 8:53 PM, Yehuda Katz <ye...@ymkatz.net> wrote:

> If you put HTML files in the htdocs folder, Apache should serve them as
> HTML and then it depends on your browser understanding the HTML properly.
> In most browsers, there is a development or debug panel that let's you see
> the raw request and response. If you are not sure how to get that or what
> the proper response values are, post specific examples (and what browser
> you are using).
> If you want to put anything more complicated than static content, you need
> to use the appropriate Apache module (for example mod_php will run PHP
> code) or CGI configuration.
>
> You should also check that your code if properly formatted - specifically
> that you have < and > and not &lt; and &gt;
>
> Sent from a gizmo with a very small keyboard and hyperactive autocorrect.
> On Dec 24, 2013 5:56 PM, "Frederick Miller" <fj...@gmail.com> wrote:
>
>> I need an example of a simple application and how to set it up on Apache
>> 2.2.  I'm running Windows XP, and I've read all the documentation.  I've
>> put some Web apps under the htdocs folder, but they just show the source
>> html and don't actually run the application.  I'd like to see an example
>> that is more than just HTML, what folder to copy it into, and what the
>> expected output is.  I've done JSPs and Servlets with Tomcat, but I'm new
>> to Apache Server 2.2.  Thanks.
>>
>> Frederick Miller
>>
>

Re: [users@httpd] Need an example of how to use Apache Server 2.2.

Posted by Yehuda Katz <ye...@ymkatz.net>.
If you put HTML files in the htdocs folder, Apache should serve them as
HTML and then it depends on your browser understanding the HTML properly.
In most browsers, there is a development or debug panel that let's you see
the raw request and response. If you are not sure how to get that or what
the proper response values are, post specific examples (and what browser
you are using).
If you want to put anything more complicated than static content, you need
to use the appropriate Apache module (for example mod_php will run PHP
code) or CGI configuration.

You should also check that your code if properly formatted - specifically
that you have < and > and not &lt; and &gt;

Sent from a gizmo with a very small keyboard and hyperactive autocorrect.
On Dec 24, 2013 5:56 PM, "Frederick Miller" <fj...@gmail.com> wrote:

> I need an example of a simple application and how to set it up on Apache
> 2.2.  I'm running Windows XP, and I've read all the documentation.  I've
> put some Web apps under the htdocs folder, but they just show the source
> html and don't actually run the application.  I'd like to see an example
> that is more than just HTML, what folder to copy it into, and what the
> expected output is.  I've done JSPs and Servlets with Tomcat, but I'm new
> to Apache Server 2.2.  Thanks.
>
> Frederick Miller
>