Apache2 server on raspberry pi will not run any php scripts - php

I have set up an apache2 server on the pi, but when trying to run any php file (placed in /var/www/html) the web page just responds with HTTP error 500. I have ran the index.html file and it works fine its only when php scripts are run that it gives me an error. I have also made sure that the php5 module is enabled in the apache configuration settings. Any advice on what to test from here would greatly help.
Update: Seems there was a problem with the permissions of the file. By giving read and write privileges by all users to the file it worked.

Related

Blank PHP page on windows server 2012

My PHP page is showing blank page when I try and run it on the server by calling the IP to the windows server and the directory to it, when I try and run HTML on the same server it works.
When I run it on Apache localhost it works perfectly as well!
Can someone tell me whats the problem?
yeah, check the apache logs! probably your error reporting is off, it might be setting in your php.ini file (you can run php --ini to see files being used if you have shell access to server), just remember, there might a separate php.ini file used for running php shell from with command and separate for when it's run through web, just remember, get the right php.ini - this will show you errors :) and then you can see whats wrong with your app... on a linux server logs should be in /var/logs/httpd(or apache2 depending on your version)
btw. check this one http://php.net/manual/en/function.error-reporting.php

How to run a PHP file from ubuntu?

How to run a php file from ubuntu platform in the localhost?
I have also installed LAMP in my system.
When I try to run the php file, in the browser, it says "The requested URL is not found-404 ERROR found".
I do not know how to proceed with this.
My php files are in the directory as shown here "/usr/var/html/a.php".
There are two options.
Access the php file through a local webserver(ie thru a local website). The web-server will deal with the requested php file. It will use either,
Inbuilt PHP module to interpret the php file, or
PHP through CGI (eg.CGI, FastCGI)
If your apache(check if apache is running using service apache2 status!!) is set to the default configuration, this could be as simple as
http://localhost/path/to/your.php
Remember by default, the base directory for apache is /var/www/html/, so you need not include this in the url.
Use the php binary directly from a terminal.
php /path/to/your/file.php
After installation of Lamp system in Ubuntu. Please follow the below two steps to run your php file.
Place your php file (.php) in /var/www/html/ (default path)
Please run url as localhost/withfilename.php
Example : I have placed welcome.php file in the /var/www/html/welcome.php
then url will be http://localhost/welcome.php

localhost downloading the *.php files instead of viewing it

I have upgraded from PHP 5.3 to PHP 5.5 (Im running Ubuntu 12.04) By removing the PHP and re-install the 5.5 version and everything worked fine during the installation,
now when i open my localhost and try to open any website on my localhost it doesn't execute index.php but it download the index.php as a text file.
i restarted Apache2 and saw this posts
nginx localhost is downloading php files in browser, instead of serving them?
and localhost doesn't execute php files after update to Maverick/Yosemite OS but it doesn't help.
Help would be appreciated,
Thanks.
Try using different browser for opening php files. It was not working for me when I opened php files using Chrome. But the same worked in Firefox browser.
You could try adding this to your conf or htaccess:
AddType application/x-httpd-php .php
or do a proper installation.
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu
i think you should take a look at your php module in your apache2. As far as i know php runs as a module in apache so search your httpd.conf for loaded modules and look at your /var/log/apache/error.log or where ever your apache error log
php is not correctly installed on your server otherwise it would have not downloaded the php file. On Ubuntu terminal try
php -v
under your
/etc/apche2/mods-enabled
see if you have php5.load in the current directory.

Restarting Apache Using PHP in IIS

I'm trying to restart my Apache2.2 webserver using a bat file that is being called by a PHP running in IIS using exec(), Apache and IIS is in the same server.
PHP code
exec("cmd /c restart.bat");
bat file
"PATH_TO_APACHE\bin\httpd.exe" -k restart -n Apache2.2
When I load my php via http to restart, I get an "Unable to open logs" error in my Apache error log file.
Majority of my search results say that there is a port 80 conflict however when I do a netstat there is none, my IIS is listening to a different port. Double-clicking the .bat file works, but running it from the PHP gets the error. Any ideas? Please advise.
IIS runs all executable scripts under the context of a specified user, usually this is the IUSR_[MACHINENAME] account.
This account can be changed in the IIS configuration in the pool configuration.
The problem you're running into is probably that this user is not allowed to access the log file location.
To track this problem down I would:
1. (dangerous, use only for testing): put the IUSR account in the local administrators group. test again. if it works, you know it is a permission problem.
2. Try using the runas command to run cmd.exe as the IUSR user and execute your command in the console window, that way you see all error messages and test more easily.
3. allow IUSR to write to the apache log location.
A whole different attempt would be to create a marker file in PHP, and use a scheduled task run as Administrator to restart apache if that marker file exists. That way you do not need to give the IUSR account more permissions and have a separate code handling the restart.

error when restarting Apache webserver

I installed Apache web server successfully.When I type the local host in browser it shows that it works. And then I save the php file to server httpdocs and restart it shows the the following alert.
Apache monitor is Already Started.
Please let me know where I am going wrong ?
You don't need to restart Apache every time you save a php file in httpdocs. just refresh you browser.

Categories