Page not found: Running a php file on an Apache sever - php

I get page not found error when I try to run my php file running on the root folder of my apache. Other php files run fine(anyway this is a magento based site). Is it because i transferred the file through FTP?
Can a server be configured not to run some specific files? How can i get round this? has is got something to do with .htacess?

Be sure you uploaded your file into the /www or /httpdocs subdirectory.
If so, check the permissions of your file.

Does the fiel have the same extension as the other php files that work.
ie. myfile.php or myfile.php4
The default config for apache specifies that php files have the extension "php4" as php version 3.0 and before are not compatible with the current versions. Usually the plain "php" extension is re-enabled but maybe not in your case.

Related

How to run PHP files on XAMMP on A Mac

I have saved a PHP file to my Applications/XAMMP/htdocs directory and I want to run it in a browser.
I have used all sorts of url combinations including:
http://localhost/xammp/htdocs/HelloWord.php
http://localhost/xammp/HelloWord.php
amongst others and I cannot find the right url.
I am using XAMPP on a Mac Majove.
If you installed the XAMPP VM version, then you can probably access it via http://192.168.64.2/HelloWord.php (check the General tab in the XAMPP app for the IP address)
If you installed the native version, then I guess it is
http://localhost/HelloWord.php
The htdocs/ folder is the document root. Its content is served under the server address. Neither the xampp nor the htdocs folder will be part of the URL. The paths are relative to the document root, and you shouldn't be able to access parent directories above htdocs/ (although server-side code such as PHP has access to the file system and may work with files outside of the document root).
First of all, expecting the php file to have information that can be visualized in a web browser, inside xampp if you have the .php file in the htdocs folder you should be able to visualize it like this:
http://localhost/HelloWord.php
Found it by trial and error, quite different from what I took from various instructions on line:
http://localhost/HelloWord.php
XAMPP's default root should be "htdocs" or "www". Put your PHP files into those folder and try again.
if it is not work, find the configuration of Apache and PHP in XAMPP folder.

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

Wamp server php.ini file

I just downloaded and installed the wamp server but the file php.ini file can not be found anywhere although the configuration page shows
C:\wamp64\bin\apache\apache2.4.17\bin\php.ini
I was wondering if somebody knows the root cause.
Is it possible to get the file from somewhere for that version?
Yes, you can get that file really easy. It's a php configuration file. If you know your installed php version go to PHP net
and download it for your version.
In there you will find php.ini-production(production settings) and php.ini-development (development setting better suited for debugging). Pick one and rename it to php.ini (php as name for file and ini being extension). Now you are ready to go after you copy it to your installation folder.
Make sure to resart your server after applying the changes.

Different include_path when run php script from command line?

I'm getting a fatal error on my require_once('directory/file.php'), "failed opening required...". I know the required file is in my php includes folder at c:\PHP_Includes\directory\file.php. When I look at phpinfo() I see the correct include_path: ".;c:\PHP_Includes"
But in the command line error it says include_path='.;C:\php\pear;C\Projects\project1\classes'
Any idea why the path seems to be different when running command line script?
The problem is related to the fact that WampServer has a multitude of php ini files. Make sure to keep them all in sync with the correct settings to avoid problems when one is used instead of the other.
Very useful info from http://forum.wampserver.com/read.php?2,72804:
There is actually 3 php.ini files in WampServer
This is how they are used...
C:\Wamp\bin\php\phpX.X.X\php.ini This is only used by wampserver and php cli exe. WampServer's menu is built using php and this is the
config file that is used. It is also used if you are using php through
the command line interface. You generally never need to edit this
file.
C:\Wamp\bin\php\phpX.X.X\phpforapache.ini This is a copy of the php.ini file used for your websites. When this version of php is being
used this file is copied into the apache bin folder. If you change
version of php the apache\bin\php.ini is then emptied and the
phpforapache.ini of the new version of php is loaded into whichever
version of apache is loaded.
C:\Wamp\bin\apache\apacheX.X.X\bin\php.ini This is the actual php.ini that is loaded for your websites. provided that this is the
version of apache being used. This is copied from the relevant active
php folder( phpforapache.ini).
This may seem a little confusing but it is nessecary for WampServer's
ability to change version of apache and php easily. The best thing to
remember is..
If you want to manually edit your php.ini file for websites then
always use the wampserver menu to open it . >> left click the
WampServer icon > php > php.ini
If you want to manually edit your php.ini file for command line then
open php.ini in the current php folder.

PHP error when i use Webception and wamp server

When I try to use Webception over wamp server on my windows 7,8 the below error appears for each tests
'php' is not recognized as an internal or external command,operable program or batch file
I have already installed php and the path is correct. Does it need more setup? How I can fix this issue ASAP?
This is because windows does not know where to find the php.exe file as it is not in a folder that is on your PATH environment variable.
However, when using WAMPServer it is a VERY BAD IDEA to add the path containing the php.exe to your PATH in the traditional way, because of course in WAMPServer it is possible to have many version of PHP available within one instance of WAMPServer.
The best solution in a WAMPServer environment is to create yourself a little command file that you can run from within a command windows that will add the php path you want to use for this specific project.
So create yourself a .cmd file and place THAT file in a folder that is already on your windows PATH environement variable.
So for example :-
File = phppath.cmd
PATH=%PATH%;c:\wamp\bin\php\php5.5.12
ECHO --------------------------------------------
php -v
ECHO --------------------------------------------
Of course you can make this as clever as you like and accept parameter specifying the php version you want to run, but untill you actually have more than one PHP version installed this is good enough.
I was also having a problem with webception on wamp failing to find php despite it being available on user and system path.
I found that wamp on windows by default does not provide environment variables to PHP.
I fixed this by editing php.ini (in apache/apache/bin/php.ini)
and ensuring that the following is set
variables_order = "EGPCS"
As at the current webception version 0.1.0 there is a bug to do with path generation that fails tests because the test file cannot be found. There is a solution for this at https://github.com/syntithenai/Webception/

Categories