Where is the httpd.conf file? - php

I had downloaded Apache Tomcat for developing Java Servelets, then I thought of using PHP also, I referred this for help on setting up Apache Server for PHP, and it says:
To configure Apache to run PHP, the httpd.conf file needs to be
modified. This file is located in the apache installation directory
under the conf folder. Open the httpd.conf file in EditRocket and do
the following:
A. Add the following line after all of the LoadModule statements:
LoadModule php5_module "c:/php/php5apache2_2.dll"
B. Search for AddType, and add the following after the last AddType
line:
AddType application/x-httpd-php .php
C. Add the PHP location to the end of the httpd.conf file. For
example, at the end of the file, add the following:
PHPIniDir "c:/php"
I looked under the C:\apache-tomcat-7.0.4\conf, but there is no file as httpd.conf.
Is there any other version which I'll have to download? Or can Tomcat run it with some plugin or something?

According to Apache Tomcat Howto, Tomcat is not capable of running PHP as it is designed only for JSP and static. Further reading shows that in order to provide your hosting for JSP, you need to install Apache webserver, and then install a web server adapter, and then modify Tomcat XML.
Modify Apache's httpd.conf file.
Install a web server adapter.
Modify Tomcat's server.xml file.
The link is old, but there are other references, and most of them will tell you to install mod_proxy in apache and send it to tomcat for your jsp app portion.
I would suggest further reading at the documentation for how to make it work, as I don't have first hand experience with it for a full explanation. Also look here for better information on how to forward apache requests to your tomcat apps.

Related

Why browser download every php file from my server? [duplicate]

Everything was going great until I added AddHandler application/x-httpd-php5s .php to the .htaccess file in my local server's document root (which I change frequently depending on the site I'm working with). Since I did that when I visit http://localhost:8888 my browser just downloads the index.php and it's not processed at all, just the raw code. Now I removed that line from the .htaccess file but I'm still having this problem.
I've found that if I add an alternative entry to my hosts file for 127.0.0.1 the new entry behaves like 'localhost' used to. But if I add the line above to my .htaccess it knocks out that new host as well. I've tried reinstalling MAMP and clearing its caches and all the temporary files I could find. I surfed through Apache's httpd.conf file all to no avail.
So, to be clear: http://localhost:8888 is experiencing the above problem. If I add a new entry to my hosts file for 127.0.0.1, say 'goomba' and the above line is not in the root .htaccess (and has never been for that host/alias/whatever) then I can access http://goomba:8888 just fine. But if I do add that line to the .htaccess then I have to add yet another entry to my hosts file to get around it even if I remove that line from the the .htaccess file.
I'm fine with using a different 127.0.0.1 alias (host? what is that called?) but it's bugging me that this is still broken.
Just to be clear, I'm on Mac OS Leopard (but I'm not using the built in Apache setup, but MAMP).
I've had a similar issue a couple times and renaming the file did not work for me. With OS X Lion I found the right configuration is this:
<IfModule php5_module>
AddType application/x-httpd-php .php
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
</IfModule>
The magic that made it work for me is the SetHandler application/x-httpd-php part.
Of course edit the <IfModule php5_module> to your php version.
You are applying a mimetype where a handler should be (see documentation on handlers)
Try this instead:
AddType application/x-httpd-php5 .php
EDIT:
As you have indicated caching modules are loaded, you could read up on caching and htcacheclean (to clear the disk cache). You can also temporarily use the CacheDisable directive. One other thing that you could also try is to rename the file that you have requested (e.g. index.php -> index.bak), request the file again in the browser (should now 404), then revert and try again.
Just note, make sure you don't have a htaccess file from your live environment accidentally downloaded with other files. Additionally, make sure you match your PHP version when editing htaccess. Wrong version cause same issue-wrong settings.
Here is an example for running PHP7:
application/x-httpd-ea-php71 .php .php7 .phtml
I hope this info can help - it happened to me 8 years after ticket is created :)
If someone has again this kind of issue, do something most important firstly. I mean, use private navigation (without cache).
I wasted my time because of this.
GLHF
Perhaps you want application/x-httpd-php5 instead of application/x-httpd-php5s? (Note the lack of an s at the end.)
in my case deleting or comment out "AddHandler php56-cgi .php" in my root's involved htacces files solved it
Best
For the same issue, i removed the '5' AddType application/x-httpd-php .php .htm .html
its working fine! try
I had the same issue and it was because inside this folder you have .htaccess file hidden with some custom code, for me was because I copy from my running website server. Try to rename the file and you will see your project. Then customise the file in your needs.
First check if your apache server is running. Start->Run->cmd and then execute command:
netstat -abn
Lookup the result for line like this:
TCP 0.0.0.0:8888 0.0.0.0:0 LISTENING 600 [apache.exe]
If you cant find anything listening on port 8888 ( no 0.0.0.0:8888 line) then your apache is failing to start. To find out why it cant start you should find apache log directory and examine the error.log (may be you have updated your php resently?). If you find 0.0.0.0:80 listening line but some other software is listening there (do you have IIS running?) then you should remove / reconfigure that softure to free port 80. If you have apache listening on port 80 but still cant open your site and you cant figure out what is causing the problem via examining apache log files then it my be database problem. Check if your mysql is running and listening using same command but you should be looking for
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING [mysqld-nt.exe]
If you cant find such line then your mysql server is not running - check mysql log files for errors. If both servers are running and you cant get any output in your browser then check your firewall and antivirus - they may block your requests. Hope this helps ;)
I actually had a very similar issue. All of my php files were downloading when I tried to test if php and apache were working together. It turns out they weren't working together.
I had to uninstall php, I would recomend the same course of action and then reinstalling php just using the zip file download on php.net, instead of installing it with MAMP. I think my problem was that I had used the php installer. I do not recomend using that.
This website helped me a lot, I was having an issue with apache not starting and while that is not your issue, this website solved both the apache not starting and the downloading of php files issue and even though you are on a mac it may help you as well http://forums.phpfreaks.com/topic/185771-problem-starting-apache-2214-after-installing-php-5212
Hope everything works! Good Luck!
Just remove the comment
<IfDefine PHP>
LoadModule php_module modules/libphp.so
</IfDefine>
in etc/extra/httpd-xampp.conf
In my case after cloning a repo and trying to set the project up i hade to run composer update to install the all dependencies and then it open the page instead of downloading the file

Apache treating PHP as comments?

I've just installed Apache and PHP. Apache appears to run php correctly, but it treats my php as comments when I delimit it with simply <?; it appears only to run code delimited with <?php
This is a problem for me because I am creating a development environment for a pretty sizeable website which I did not build. (Don't want to have to go through hundreds of files and change a lot of tags.)
What can I do to get it to treat all <? tags as php start tags?
Details:
Running Apache 2.2.19, PHP 5.2.17, Windows XP
To get Apache to run PHP, I added the following lines to the config file:
LoadModule php5_module "C:/Program Files/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
PHPIniDir "C:/Program Files/php"
Check your php.ini. Make sure short_open_tag is set properly (i.e., you want it to be set to On).
This is a php configuration question. You just need to set
short_open_tag = On
You would need to turn on short_open_tag in the php.ini file. You can read more about this file here.
It's quite simple really. All you have to do is install the HTML in the root of your Apache PHP JavaQuery XRSS folder and then run the script that gets generated. After the script is run type in "22145" and it will run a PHP script that changes the way PHP is interpreted by the Internet and make it so you don't have to use the <?php tag on your Silverlight Python C++ encoding applet.

Server Downloading File Instead Of Showing It

I have a Apache server running at Rackspace Cloud Hosting, so I've installed Wordpress manually(setting up the database, wget the latest.zip...) and placed it at /var/www, but now when I try to access it for the first time, it downloads a strange file with the IP as name instead of showing me the Wordpress Installation.
PS: The same happens if I place it on a sub-directory like blog
I think you haven't configured Apache to execute PHP (mod_php?) Right now it's just serving your PHP files like any old file type so what you're getting is your wordpress index.php as a file download.
I'm not sure what the process is for Rackspace, but usually this would mean enabling mod_php.
Do you have any other PHP files that work on that site?
you need to tell Apache to excuate php files. add the following to your Apache configuration file:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php
make sure PHP module is included in Apache configuration first!

PHP files are downloaded by browser instead of processed by local dev server (MAMP)

Everything was going great until I added AddHandler application/x-httpd-php5s .php to the .htaccess file in my local server's document root (which I change frequently depending on the site I'm working with). Since I did that when I visit http://localhost:8888 my browser just downloads the index.php and it's not processed at all, just the raw code. Now I removed that line from the .htaccess file but I'm still having this problem.
I've found that if I add an alternative entry to my hosts file for 127.0.0.1 the new entry behaves like 'localhost' used to. But if I add the line above to my .htaccess it knocks out that new host as well. I've tried reinstalling MAMP and clearing its caches and all the temporary files I could find. I surfed through Apache's httpd.conf file all to no avail.
So, to be clear: http://localhost:8888 is experiencing the above problem. If I add a new entry to my hosts file for 127.0.0.1, say 'goomba' and the above line is not in the root .htaccess (and has never been for that host/alias/whatever) then I can access http://goomba:8888 just fine. But if I do add that line to the .htaccess then I have to add yet another entry to my hosts file to get around it even if I remove that line from the the .htaccess file.
I'm fine with using a different 127.0.0.1 alias (host? what is that called?) but it's bugging me that this is still broken.
Just to be clear, I'm on Mac OS Leopard (but I'm not using the built in Apache setup, but MAMP).
I've had a similar issue a couple times and renaming the file did not work for me. With OS X Lion I found the right configuration is this:
<IfModule php5_module>
AddType application/x-httpd-php .php
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
</IfModule>
The magic that made it work for me is the SetHandler application/x-httpd-php part.
Of course edit the <IfModule php5_module> to your php version.
You are applying a mimetype where a handler should be (see documentation on handlers)
Try this instead:
AddType application/x-httpd-php5 .php
EDIT:
As you have indicated caching modules are loaded, you could read up on caching and htcacheclean (to clear the disk cache). You can also temporarily use the CacheDisable directive. One other thing that you could also try is to rename the file that you have requested (e.g. index.php -> index.bak), request the file again in the browser (should now 404), then revert and try again.
Just note, make sure you don't have a htaccess file from your live environment accidentally downloaded with other files. Additionally, make sure you match your PHP version when editing htaccess. Wrong version cause same issue-wrong settings.
Here is an example for running PHP7:
application/x-httpd-ea-php71 .php .php7 .phtml
I hope this info can help - it happened to me 8 years after ticket is created :)
If someone has again this kind of issue, do something most important firstly. I mean, use private navigation (without cache).
I wasted my time because of this.
GLHF
Perhaps you want application/x-httpd-php5 instead of application/x-httpd-php5s? (Note the lack of an s at the end.)
in my case deleting or comment out "AddHandler php56-cgi .php" in my root's involved htacces files solved it
Best
For the same issue, i removed the '5' AddType application/x-httpd-php .php .htm .html
its working fine! try
I had the same issue and it was because inside this folder you have .htaccess file hidden with some custom code, for me was because I copy from my running website server. Try to rename the file and you will see your project. Then customise the file in your needs.
First check if your apache server is running. Start->Run->cmd and then execute command:
netstat -abn
Lookup the result for line like this:
TCP 0.0.0.0:8888 0.0.0.0:0 LISTENING 600 [apache.exe]
If you cant find anything listening on port 8888 ( no 0.0.0.0:8888 line) then your apache is failing to start. To find out why it cant start you should find apache log directory and examine the error.log (may be you have updated your php resently?). If you find 0.0.0.0:80 listening line but some other software is listening there (do you have IIS running?) then you should remove / reconfigure that softure to free port 80. If you have apache listening on port 80 but still cant open your site and you cant figure out what is causing the problem via examining apache log files then it my be database problem. Check if your mysql is running and listening using same command but you should be looking for
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING [mysqld-nt.exe]
If you cant find such line then your mysql server is not running - check mysql log files for errors. If both servers are running and you cant get any output in your browser then check your firewall and antivirus - they may block your requests. Hope this helps ;)
I actually had a very similar issue. All of my php files were downloading when I tried to test if php and apache were working together. It turns out they weren't working together.
I had to uninstall php, I would recomend the same course of action and then reinstalling php just using the zip file download on php.net, instead of installing it with MAMP. I think my problem was that I had used the php installer. I do not recomend using that.
This website helped me a lot, I was having an issue with apache not starting and while that is not your issue, this website solved both the apache not starting and the downloading of php files issue and even though you are on a mac it may help you as well http://forums.phpfreaks.com/topic/185771-problem-starting-apache-2214-after-installing-php-5212
Hope everything works! Good Luck!
Just remove the comment
<IfDefine PHP>
LoadModule php_module modules/libphp.so
</IfDefine>
in etc/extra/httpd-xampp.conf
In my case after cloning a repo and trying to set the project up i hade to run composer update to install the all dependencies and then it open the page instead of downloading the file

How to support "AddType x-mapp-php5 .php" on my development machine

My ISP requires me to put the following in my .htaccess files:
AddType x-mapp-php5 .php
But that breaks my development machine.
I don't really understand what that directive is for, but I'm sick of commenting it out for dev, and uncommenting it whenever I need to upload a new version.
Is there some way of supporting it in dev?
You could try the <IfModule> Apache directive to distinguish your development machine from the production machine.
E.g. the following would work if you're running PHP as an Apache module, and your ISP runs it as CGI:
<IfModule !mod_php5.c>
AddType x-mapp-php5 .php
</IfModule>
You could also check for the existence of a PHP4 module.
Or you could pass a startup parameter to Apache on your development machine and check for that using <IfDefine>.
This merely tells the web server that files with the extension .php are to be handled by the PHP module.
But I would recommend asking web-server related questions on serverfault.com, where your question won't get closed (with the reason belongs on serverfault.com) and where you will receive much better answers than here.

Categories