Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php code

Status
Not open for further replies.

dendic

Programmer
Jan 19, 2003
106
US
Windows 8.1 Apache 2.4.20
PHP 5.5.15
When I run a php file only the code shows in the browser (chrome). I searched all over the internet but find no solutions. I tried altering the apache config with no success. Please help
 
For PHP questions please post in forum434.

How did you install PHP?

How are you attempting to run the php file?

Are you going through a fully qualified domain url? Or simply attempting to open a php file by double clicking or using the Open File option from the browsers file menu?





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thanks for answering so quickly. I downloaded xammp from apache and friends. Using local host. I just sent a simple PHP file:
<?php
echo "PHP works";
?>
The output on the browser shows the code and not (PHP works)
I've been all over the internet and can't find a solution please help.
 

Does your file name end in .php or .html?






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Is the PHP module loaded in the Apache configuration?
Code:
LoadModule php5_module /lib/apache2/modules/libphp5.so




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I have this loaded:
LoadModule php5_module C:/xampp/php/php5apache2_4.dll
LoadModule php5_module /lib/apache2/modules/libphp5.so
The problem remains
 
I did not realize this was on Windows. You can remove the line I posted above, as that is the Path for Unix installations.

In any case, make sure your php file is executable, right clicking on the file, and setting the permissions for the Apache user to read, write, and execute.

Also, make sure you are opening your files similar to in your browser, rather than file:///c:/xamp/htdocs/filename.php

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
When I typed it in the way you said I got access forbidden error (no permission) Error 403. But the application I'm using is Laravel. Do I need to adjust the Apache config and localhost to point to the htdocs directory?
 
When you install XAMPP, you will have a administration panel when just browsing
Applications (or Frameworks) are either installed in subdirectories of htdocs or you add Aliases to apaches httpd.conf pointing to other directories. This seems to be done already, otherwise you would only get 404 not found errors, not permission errors. If you started Apache as service, the account used by apache will need permissions to the Laravel directory. It may be easier to install Laravel into htdocs, as that inherits permissions.

If you start learning, you may start off with pure PHP first, and maybe a few basics about Windows file system permissions, services and system accounts?
It may be easier fpr you to find hosting including a preinstalled apache,php and Laravel.

Bye, Olaf.
 
I have full permissions set for both htdocs and laravel directories. At this point all I would like to do is make a simple PHP file and get apache to recognize it. I'm not familiar on how to start Apache as a service I a merely use a gui control pane. I do have artisan running as a service but the problem appears where it's running or not.
 
Apache should already be pointing to the htdocs director.

What happens if you open only?

Do You get the "Apache is up" page?





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
>I have full permissions set for both htdocs and laravel directories

There often is a simple misunderstanding about Windows file system permissions. If you add the "account" All/everyone, this doesn't include some Windows system accounts. Anyway, this mostly only plays a role, if you run Apache as a service, if you start a normal process from the Xampp panel it'll run with your account and privileges.

As Vacunita said Apache itself will be configured for htdocs by default, so what did you actually do in apache config?

Xampp installs both apache and php and you just have to start Apache and php is executed, the whole xampp administrative panel you see when browsing is running on php.

Bye, Olaf.
 
When I typed localhost I got page cannot be displayed.
 
Then apache doesn't run. If you install xampp you get a xampp control panel installed, from where you can start apache http server, mysql database, filezilla ftp server (if installed) and mercury mail server (if installed). Look out for that and start apache from there.

Bye, Olaf.
 
It wasn't running my bad but now I get.
Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.

Error 403

localhost
Apache/2.4.10 (Win32) PHP/5.5.15 OpenSSL/1.0.1i
 
After a normal install of XAMPP the htdoc will be configured and permissions granted and there is nothing to do but start apache. So uninstall and reinstall.

Bye, Olaf.
 
My last thought before re-installing I have a 64 bit machine would it have made a difference if I installed the 32 bit version of apache?
 
If 64bit systems could only run 64bit software you'd not have much more than the OS.

As far as I see there is no 64bit version of XAMPP downloads and you don't need one.

When you install change install location to C:\XAMPP for example or any other directory outside of program files, as system folders are only writable for setup via elevated priviliges during installs.

Also don't change any of the defaults. If asked whether to install Apache as service, don't, that also adds to the problem of htdocs access, as already said. By default two normal apache processes running with your own user account will be started by the xampp control panel, one for http, one for https.

If it still doesn't work, maybe something else on your system is already making use of port 80, eg IIS.

Bye, Olaf.
 
Apache is running on port 80 for sure and xampp is at the C:/xampp. I guess all that's left is re-install. I will inform you of the results after.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top