How to Run PHP Scripts
I have a new problem now. I have installed Redhat 9.0 and Apache, PHP and MySQL are packages that came with RH9. I was able to initialise and start Apache and MySql. But coming to PHP, i dont know how to initialize it. From some of my friends i came to know that Apache+LINUX have the feature of automatically executing PHP scripts too. But when i created a basic HTML file "Hello World" and tried to open it..it shows me the entire HTML code..i dont know where to save the PHP and HTML files that i create and how can i view my HTML File.I tried saving the HTML file in var/www/HTML/mrtg folder and open my file. all the files in the folder open up except for my file. Please help me in this so that i can go ahead and start my web application. There are no syntax errors in my file thats for sure...the code in my file goes like this
Checking the file
Do i need to edit the httpd.conf file to initialise it to run PHP. if yes how can i go about doing that.
I think your post is a bit unclear.
I assume you have not modified httpd.conf and that the service is running?
By default the Apache server is using /var/www/html as default diectory.
If you open a browser and type http://localhost than you should see a page appearing. It has some textsaying that your server is up and running.
Place a file in this directory and named it, for example, test.php
Insert the following in the file
now run http://localhost/test.php and if php is running you should see a page with a lot of details on your apache/php setup
<? phpinfo(); ?>
try this first. I am not sure if you have to enable php in httpd.conf when you install it from the packages.
I added the following manually om my freebsd box
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
You need to uncomment the php-module in /etc/httpd/conf/httpd.conf and the just put a index.php file in your wepagedirectory... try to create and index with this text in...
echo "Hello World....do you see this text??";
there is a very detailed guide in the official php website, www.php.net
I am working on it as well. LOL
Thanks everyone. I am able to run my php pages now. I had to edit the httpd.conf file and add in the loadModule and addApplicationType and it worked. Thanks again. This forum is a lot more helpful to me.
Good...thats why we are here...to help people.