404 not found error on localhost .php file - php

I'm just starting to learn php programing and I'm having this frustrating problem that does not let me to go on.
I just set up LAMP server on my linux mint with default settings on localhost. Problem is that when I create .php file in var/www browser can not find it and shows 404 not found message.
When I created info file to view php info everything worked fine,
<?php info(); ?>
when creating new random php file in same location then the error comes up.
I lost whole day looking for an answer but not luck.

I tried to reinstall the LAMP and it gave me the same result.
Then I found a post that suggested, default location for .php files might be in /var/www/html and not /var/www, so I tried that and it worked.
Hope somebody will find this helpful.

You are using incorrect function.
<?php phpinfo(); ?>

I am working on windows, but the issue might be the same - just use a root directory which doesn't have whitespaces. ~~ hope it helps

Related

After changing filename from index.html to index.php my project is no longer served with MAMP

I'm trying to do some PHP learnin' but I've run into a road-block. I have MAMP installed and I am successfully serving my project files locally. However, after renaming my index.html file to index.php, the page is no longer served.
url is: localhost/projectfile/
I can rename the file back to index.html and the page will serve up again but this means my php code won't run.
I've tried digging around MAMP to see if there is some information/ setting that could help but I'm not finding a solution. It would be great if anyone has info on how this could be solved. Thanks!
You will find all the "start page" stuff in MAMP/bin/mamp (e.g. the English language page is MAMP/bin/mamp/English/index.php).
This is due to the following line in MAMP/conf/apache/httpd.conf:
Alias /MAMP "/Applications/MAMP/bin/mamp"
Refer Where is the index.* file that is served as the MAMP start page URL?
For anyone viewing this post- I must have edited a config file in the wrong way. I uninstalled MAMP and reinstalled and everything seems to be working properly now.

Local xampp wordpress installation - cannot find wp-blog-header.php

I'm working locally with XAMPP and Wordpress and I'm struggling with what is probably a very basic config issue. I'm not a professional IT guy, just a hobbyist hacker so I apologise in advance if I'm being a bit dumb but hopefully somebody can kindly offer some assistance here.
I've installed xampp locally on my iMac. I've then installed wordpress using the xampp wordpress installation package. Both seem to be working fine. To test the web server I created a simple .php test file and this generated the expected output when I entered "localhost/hello.php" into my browser. As far as wordpress is concerned entering "localhost/wordpress" gives me access the local wp interface to create and edit posts, change display settings etc etc. So far so good...
Now I want to create a new .php file that includes the instruction:
require('XXX/wp-blog-header.php')
where the "XXX" is obviously the relevant directory path for the wp header file.
I cannot find this file, or indeed local wordpress files, anywhere (and I've searched extensively). In the "home" location for "localhost" (which I know from my "hello.php" test) there isn't even a wordpress directory so I'm totally puzzled as to how typing "localhost/wordpress" in my browser is accessing the local wp installation or how to go about determining the correct directory path for the wp header file I'm looking for?
I do understand that with this stack a great deal of info will either be generated on the fly, or stored in the local mysql database as opposed to the file structure, but I thought I would find some reference or alias somewhere to help me trace this through and determine what path to include in my .php file for wp-blog-header.php.
I've searched this forum and while there are several related questions I haven't found anything that helps me with this particular issue.
Thanks vm,
Ian
The location of your Wordpress files is:
/Applications/XAMPP/xamppfiles/apps/wordpress
Ok I found the path I needed and (partially) understand why I couldn't locate it. As Scriptonomy helped me identify the Wordpress files are held at:
/Applications/XAMPP/xamppfiles/apps/wordpress
While my test.php file is held at:
/Applications/XAMPP/xamppfiles/htdocs/test.php
The reason I couldn't locate either wp-blog-header.php or wp-load.php is because these there is an another "htdocs" sub-dir under the wordpress install location i.e.:
../apps/wordpress/htdocs
However I (as user "admin") don't have access to read this directory and so couldn't see the contents and therefore couldn't find the files. The permissions on the directory belong to "daemon" which I guess was the XAMPP installer package? Setting the directory path in my test.php file to:
../apps/wordpress/htdocs/wp-load.php
somehow the web server (?) can read the file (even though I can't see it myself via the Finder application) and so the code is now giving the expected result.
So problem solved even if I don't quite understand the solution!
Thanks for replies which helped me eventually get to a solution!
Cheers,
Ian

Trying to install an apache website, but getting some weird endless errors

https://github.com/kokspflanze/PServerCMSfull
^ I've been trying to install this website since 2 days, and I've done everything mentioned there properly, I dunno if I should do extra steps/modifications to the files. First, localhost was working fine but the when I surf localhost/pservercmsfull I see the directory files/folders but not the site content, a screenshot to explain what I meant: http://prntscr.com/7vuu4x
Then I've checked httpd.conf again and found a typo, I've fixed it then localhost started saying the following; Forbidden
You don't have permission to access / on this server.
Thanks for reading, if you know any possible solution/something I should do but not mentioned in github, please let me know what is it and some hints to do it.
you have to set the DocumentRoot to the public directory, that is the current problem.
i write this steps there https://github.com/kokspflanze/PServerCMSfull#step-3-configuration-for-apache
The simple solution is to either rename 'init_autoloader.php' to 'index.php', or to create a new file called 'index.php' which consists of the following:
<?php include_once('init_autoloader.php'); ?>
In your Apache2 vhosts file, there is a parameter called 'DirectoryIndex' which defines which filename to render, if present, instead of showing the directory listing. More information on that can be found here.

How to access phpinfo.php?

I am trying to access
http://localhost/phpinfo.php
but I can't find a way to get there on the local machine I made the update on.
This is part of a FastCGI installation to Host PHP Applications on IIS 6.0.
I followed steps here: 'Test PHP CGI' in http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php-applications-on-iis-60
I copied phpinfo.php as indicated in the link above in the F:\Inetpub\wwwroot directory as indicated here http://msdn.microsoft.com/en-us/library/ms474356(v=office.12).ASPX
then tried to access
http://localhost/phpinfo.php
but I don't get anywhere (I get: 'The webpage cannot be found' error message).
Any help is appreciated.
Thanks,
Izumi.
You should be able to get all the information by saving a file with the following:
<?php
phpinfo();
?>
and simply view that page.
While you are testing, you can drop it anywhere you like, but obviously remove it from a production box as anyone will be able to see it.
I had to add the .php extension in the IIS Web Sites Properties as indicated here http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php-applications-on-iis-60 under 'MANUALLY CONFIGURE THE FASTCGI EXTENSION TO WORK WITH PHP'
I am not sure why the script didn't do it for me. Maybe because I had two domain names on that server.
Thanks for your help!
Izumi.

Apache doesn't execute my copied PHP files, but testing.php works

I've just installed LAMP on my Ubuntu 9.10 machine, and everything works fine except when I copy my PHP files from another computer.
The LAMP guides I've followed also made me create a phpinfo() test file, which works, but when I try to type in e.g. index.php absolutely nothing happens - just a blank page in FireFox. :(
The files are in the exact same directory.
I'm thinking it's probably something with permissions and so on, but since I'm new to both PHP and Ubuntu, I'm kind of lost. It's like I can't create a PHP file with my file browser, but only by using the terminal - like when I created the testing.php from the LAMP guide.
Whaddayaknow... I made an error, tried to:
echo "Hello" world
which, even though I'm a PHP noob, I clearly know is wrong.
I think I'll have to figure out how to enable some sort of error reporting, a blank page is clearly not good enough.
You mean you have a index.php (copied from another computer) and a test.php (edited by hand, with a call to phpinfo()) in the same apache directory, the second works from your browser and the first doesnt ?
That can be a permission issue, or some compilation error in your php.
About permissions, for files should be readable from the apache server (more precisely, form the user that runs the apache server). You can type chmod a+r index.php.
YOu can also check your apache error logs (location dependent on installation). In any case it's vital to know where the error logs are if your are developing a web site.

Categories