Downloads files instead of opening them - php

I downloaded EasyPHP 14.1 VC9, and downloaded all of my files from my webhost (new computer). Now when going to any folder below the data/localweb/ level just causes my browser to download the file instead of executing and opening it.
For example:
data/localweb/index.php works fine.
data/localweb/somefolder/index.php doesn't work.
No wordpress or any craziness, just vanilla PHP. Any PHP on the root folder works fine, but my server architecture is just folders off the root - any way to keep it and have PHP find ALL php files and execute them as long as they are under the root folder?
I have these lines in the Apache config:
AddType application/x-httpd-php .phtml .pwml .php5 .php4 .php3 .php2 .php .inc
LoadModule php5_module "${path}/binaries/php/php_runningversion/php5apache2_4.dll"
OS: Win7 Home Premium 64bit

facepalm
Let this be a lesson learned for everyone out there.
The key we should be looking for from now on is 'downloaded from webhost'.
My somefolder/ contained an extra .htaccess that was from my webhost. Deleting it solved the problem.

Related

How to edit security.limit_extensions on Azure App Service on Linux

How are you able to change the security.limit_extensions directive on Azure App Service for Linux when running PHP 8 or 8.1 (Nginx rather than Apache)?
I have changed all of the usual places (including /usr/local/etc/php-fpm.conf) but none are having an impact. I understand this will need a bash script to update each restart, and have this working for php.ini values, but cannot get this to work for FPM values. Currently have the following error when parsing HTML as PHP, with NGINX blocks seemingly setup correctly:
[ERROR] NOTICE: Access to the script '/home/site/wwwroot/login.html' has been denied (see security.limit_extensions)
You have probably already created a custom nginx config file and set up /home/site/startup.sh to copy it in place and reload nginx.
The principal is the same.
cp /usr/local/php-fpm.d/www.conf /home/site
Edit /home/site/www.conf and comment out the security.limit_extensions line and add some extensions:
security.limit_extensions = .php .php3 .php4 .php5 .php7 .html .htm
Edit /home/site/startup.sh to add the following line before the nginx reload:
cp /home/site/www.conf /usr/local/etc/php-fpm.d/www.conf
Restart your web app.

PHP test page is showing blank

I am trying to set up PHP to work with Apache using Apache Module DLL. The following code is added to c:\Apache24\conf\httpd.conf file:
LoadModule php5_module C:/PHP/php5apache2_4.dll
<IfModule php5_module>
DirectoryIndex index.html index.php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP"
</IfModule>
Then I browse http://localhost in a browser and it shows a page saying "It Works!"
Then again I test browse a PHP page info.php which just calls phpinfo() and it shows quite a bit of info about PHP installation.
Now, the case is that I found two default files such as php.ini-production and php.ini-development and I copy any one of them and save it as php.ini in
"C:/PHP",restarts the Apache server and again test browse info.php,then this time the page is blank even without any error message.
What might be the issue and how should I try to solve it?
My software specification is outlined below:
OS: Windows 7
PHP: 5.6.29
Apache: 2.4.23-win32-VC14
Thanks in advance!

Installing PHP, MySql and Apache on windows

Its my first time working with Apache,PHP,MySql. I downloaded and installed the latest package of these 3. Now I checked with apache and the index.html works. Now I replaced the index.html with some php script to check if my php works or not. When opened the html page again I see the php code directly. It seems it does not work. following is how my php code looks like.
<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>
when I open my index.php , I see the above code itself. Can anybody let me know whats wrong and how can i fix it?
Check your apache httpd.conf file for some commented out code that looks like this
LoadModule php5_module libexec/apache2/libphp5.so
and further down the file, this...
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
it seems there is some problem in the installation. use WAMP as stefan and dessus or XAMPP. i recomand u to use XAMPP its bundled with APACHE, MYSQL, File Zilla Server, Mercury for mail. Easy to Install and Use . http://www.apachefriends.org/en/xampp.html
Another vote for WampServer. Once you have a working server, it's then easier to poke around with configurations files and then learn Apache/PHP configuration that way.
use wamp! it's easy and fast :)
http://www.wampserver.com/en/
personally, i use an old version from 2007, 1.7.4, it can be found here: http://sourceforge.net/projects/wampserver/files%2FWAMP5/
the good thing about using an old version is that your code will work on old machines, and many servers out there have old versions of php and mysql.
the bad thing about using an old version is that your code might not work on new machines, and some machines out there have new versions of php and mysql.
http://computing-know.blogspot.in/#!/2013/10/how-to-setup-apache-php-mysql.html
Step By Step Process to Setup Apaache,PHP,Mysql,phpMyAdmin and XDebug.
1)How to install Apache
2)Setup PHP for Apache
3)Install & Configure MySQL to use with PHP
4)Setup XDebug for Debugging
5)phpMyAdmin
Note:In this tutorial my Server Folder is located on F:\Server
How to install Apache
1)There are two ways to install apache either install the old version of apache httpd (Compatible with Windows XP) from httpd.apache.org/download.cgi or get the latest apache build zip from www.apachelounge.com/download/ .
2)I will show how to configure apache from the zip version downloaded from apachelounge.com/download/ .
3)Click on Additional + VC9 on the left of the page.
4)Download the 2.4.x zip build with OpenSSL 0.9.8.
5)Create a folder with a name Server on location where .
6)My Location is F:\Server
7)Extract the Apache24 from apache zip to the Server folder.
8)Now Goto config folder in Apache and open httpd.config in any text editor.
9)Find(Ctrl + F) and replace each and every instance of "c:/Apache24" and change it to your apache location in my case its f:/Server/Apaache24.
ServerRoot "c:/Apache24" with ServerRoot "f:/Server/Apache24"
DocumentRoot "c:/Apache24/htdocs" with DocumentRoot "f:/Server/Apache24/htdocs"
with
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/" with ScriptAlias /cgi-bin/ "f:/Server/Apache24/cgi-bin/"
with
8)Now run the Command Prompt (with Administrator Rights) .
9)On Command Prompt go to the location Server/Apache24/bin .
10)Inside the Bin folder type "httpd -k install" to install the Apache service and then press Enter.
11)To start the Apache Server simply type in "httpd -k start" and then press Enter.
12)Restart Your Computer
13)Now Open the Bin folder and double click on the ApacheMonitor.exe and Start Apache
14)Now Goto localhost if you see page "It Works" then Apache is sucessfully installed on you computer.
If you see a page that says "It works!" then the Apache server has been installed successfully.
Setup PHP for Apache
1)Goto windows.php.net/download/ download the php-5.4.x-Win32-VC9-x86.zip.
2)Create a folder named php inside Server folder.
3)Extract all files from php-5.4.x-Win32-VC9-x86.zip to php folder in the Server.
4)Now Goto config folder in Apache and open httpd.config in any text editor.
5)Find(Ctrl + F) the LoadModule scroll down until last LoadModule and Paste the following
LoadModule php5_module "f:/Server/php/php5apache2_4.dll".
6) Find(Ctrl + F) the AddType scroll down until last AddType and Paste the following
AddType application/x-httpd-php .php .
7)Add the PHP location to the end of the httpd.conf file. For example, at the end of the file, add the following: PHPIniDir "Your PHP Location".
localhost/info.php
8)In the php folder rename the php.ini-development to php.ini and open it in Text Editor.
9)Find(Ctrl + F) the display_errors, and make sure the value is set to On.
10) Find(Ctrl + F) the extension_dir = "./" and change it to extension_dir = "F:\Server\php\ext" .
11)Restart Apache Server.
12)Create a file "phpinfo.php" in htdocs folder in Apache with follwoing content:
13)Goto localhost/phpinfo.php
extension_dir = "./"
14)Right Click MyComputer Click Propertes
15)Click Environment Variables
16)Add Your php folder location at the end of the path
17)Restart Your Computer.
Install & Configure MySQL to use with PHP
1)Goto dev.mysql.com/downloads/mysql/ download the zip or installer version.
2)Install MySQL
3)Click Next
4)Select Complete & click Next
5)Click Finsh
6)Click Standard Configuration
7)Click Next
8)Enter the password for mySQL
9)Goto MySQL Command Line and enter the password.
12)Open the php.ini file and find the line: ;extension=php_mysql.dll remove the semi-colon.
and find the line: ;extension=php_mysql.dll
phpMyAdmin
1)Goto config folder in Apache and open httpd.config in any text editor.
2) Find(Ctrl + F) the line DirectoryIndex index.html add index.php.
3)Open php.ini file in the Server Folder and Uncomment the mbstring and mysqli extension.
3)Goto phpmyadmin.net/ Download the latest phpMyAdmin-4.0.8-english.zip.
4)Extract it to phpMyAdmin folder in htdocs.
5)Restart the Apache Server.
6)Goto localhost/phpMyAdmin/
Setup XDebug for Debugging
1)Goto http://xdebug.org/download.php from your browser and download the
php_xdebug-2.x.x-5.4-vc9 Thread Safe 32 bit version.
2)Copy and Paste it to the extension folder in the php.
3)Copy & Paste the following line of code at the end of php.ini file .
[XDebug]
;; Only Zend OR (!) XDebug
zend_extension="Your Location of Xdebug"
xdebug.remote_enable=true
xdebug.remote_host=localhost
xdebug.remote_port=10000
xdebug.remote_handler=dbgp
4)Restart Apache Server.
5)Goto to localhost/phpinfo.php scroll down to see if xDebug is installed

smarty and suphp permissions - saving as different user

Right now i have to give 777 permission to the directory where files are saved and instead of saving it as "user1" is saving it as apache
-rwxrwxrwx 1 apache apache 6865 Aug 30 17:20 homepage.tpl.php
How can the files be saved as user1 and without 777 permission outside my docroot wich is home/user1/public_html/
lets say in /home/user1/private/homepage.tpl.php
Im using a Centos LAMP with suPHP.
Thanks in advance.
Solved
To fix it I had to reinstall suphp with this conf.
/etc/suphp.conf
check_vhost_docroot=true
and use the correct handlers
[handlers]
;Handler for php-scripts
x-httpd-php="php:/usr/bin/php-cgi"
;Handler for CGI-scripts
x-suphp-cgi="execute:!self"
Inside the virtual host
suPHP_Engine on
suPHP_UserGroup user user
AddHandler x-httpd-php .php .php3 .php4 .php5
suPHP_AddHandler x-httpd-php

phpmyadmin - save file to disk

when i point my browser to http://localhost/phpmyadmin, instead of showing me its front page, it comes up with save as dialog.
I'm running:
Apache/2.2.3 (Debian) PHP/5.2.0-8+etch13 Server
I've reinstalled both apache2 and php5.
After re-install i don't have httpd.conf file, how can i get it back? Is there a standard file which i can just copy into /etc/apache2?
I did a locate httpd.conf and the only file i got was the empty file i have under /etc/apache2/ which i made.
Did you configure the php extension to send an http header?
In httpd.conf:
AddType application/x-httpd-php .php
EDIT
The file is not necessarily named httpd.conf, that's just the default name. Try searching for other configuration files in the Apache directory -- the extension probably is .conf but it might be something else...
If you used apt-get on debian to install apache2, try /etc/apache2/apche2.conf
/EDIT
I also get this problem when I install ISPconfig. I solved the problem by this tutorial:
http://www.howtoforge.com/perfect-server-debian-wheezy-apache2-bind-dovecot-ispconfig-3-p4
I think the main code is change suphp.conf config.
sudo nano /etc/apache2/mods-available/suphp.conf
comment out the <FilesMatch "\.ph(p3?|tml)$"> section and add the line AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml - otherwise all PHP files will be run by SuPHP
<IfModule mod_suphp.c>
#<FilesMatch "\.ph(p3?|tml)$">
# SetHandler application/x-httpd-suphp
#</FilesMatch>
AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml
suPHP_AddHandler application/x-httpd-suphp
<Directory />
suPHP_Engine on
</Directory>
# By default, disable suPHP for debian packaged web applications as files
# are owned by root and cannot be executed by suPHP because of min_uid.
<Directory /usr/share>
suPHP_Engine off
</Directory>
# # Use a specific php config file (a dir which contains a php.ini file)
# suPHP_ConfigPath /etc/php5/cgi/suphp/
# # Tells mod_suphp NOT to handle requests with the type <mime-type>.
# suPHP_RemoveHandler <mime-type>
</IfModule>
Hope I can help someone :)
I think you just do not know where that config file is. I don't think apache can run without httpd.conf. Here is how you can find your config:
$>locate httpd.conf
/etc/httpd/conf/httpd.conf
$>vim /etc/httpd/conf/httpd.conf
Once you located it, find where other AddType reside and add
AddType application/x-httpd-php .php
Last thing you need to do is restart your httpd, it depends on install, but doing apachectl restart does the trick. You might have to locate it just like you did with httpd.conf file and type in the entire path to the file.
Afterwords, your phpmyadmin should come up.
I dont know anything about this but... does someone knows a way in javascript to download selected files, for example I select through checkboxes 2 files, and then I click on a button in order to download these 2 files choosing the route where i will save the archives

Categories