We help IT Professionals succeed at work.

VI PHP Files only HTML

kevbob650
kevbob650 asked
on
I'm trying to create some new files in VI on a linux platform.  No matter how I create the file (touch file.php or vi ) the file will be an html file with no php???
vi-screenshot.jpg
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2004

Commented:
When you request the file, the server passes the contents of the file to the PHP parser.  The PHP parser returns a response.  If everything works out OK, the server set a content type of text/html.  In your browser, you will see whatever was put out by the script.
CERTIFIED EXPERT
Top Expert 2014

Commented:
I will assume you are using Apache as your webserver.

There are two ways to get Apache to execute PHP to create dynamic web page.  One way, original way, is to have the PHP files in a directory that is defined as a CGI directory.  In this setup you have a PHP script that dynamically generates the whole webpage, that is all HTML code.

The second way, used more often today, is to have the PHP module installed and then you can then have PHP code in-line of a html file and the files can reside anywhere.  In this setup the PHP code just generates small parts of the html code.

Which method are you using?

Author

Commented:
Well I have 30+ php files working just fine but when I go to create a new file, I get nothing. I should be able to do a simple echo to test the page but nothing is returned. when I view the file I see an html header but not my echo. All my php code resides in an /opt/web/html/ directory. Again, all of my existing files work fine but creating a new file doesn't work. this is all happending on a new server after a painful server move. Can you tell I'm not a linux guy!
CERTIFIED EXPERT
Top Expert 2014
Commented:
Do you have shell access?  Can you do a ls -l of the files in that directory?

Check to see if the file permissions are the same.

Could be that the default permissions are different between the old and new box.
CERTIFIED EXPERT
Top Expert 2004

Commented:
Also, make sure you have configured the PHP error log, and configured PHP to show startup errors.  It sounds like PHP may be having an issue accessing the file.  Perhaps you have a global open_basedir directive set?

Author

Commented:
yeah, it was those pesky permissions - thanks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.