Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Hi, Where can I get detailed info regarding how to configure and use Apache along with PHP. I have Red Hat 8.0 and have installed Apache Server, PHP and MySQL ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2003
    Posts
    10

    Configure Apache and PHP


    Hi,

    Where can I get detailed info regarding how to configure and use Apache along with PHP. I have Red Hat 8.0 and have installed Apache Server, PHP and MySQL thats available in the packages. MySQL is working fine.
    Also http://localhost displays the page fine. I need to setup a PHP site in my computer, so I need to know how to go about configuring it ir is it already preconfigured when I had installed it ?

    Also are there any GUI tools available to configure them or do I need to edit files and if so which files are those.

    Thanks.

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    If you've install PHP from an RPM (or from the system installation, that's the same thing), then it's already configured. Just create a .php file and try it out.
    If you want PHP to be able to use MySQL, make sure that you have the php-mysql package installed.

  3. #3
    Linux Engineer
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    796
    Just create a index.php page and put it under your webbpage directory with follwing text in it.

    Code:
    <?php
    
    print "Does my PHP-engine work?? \n";
    
    ?>
    If it workes the text will apear on your monitor, otherwise install PHP from rource or from rpm. Make sure to enable mysql-support if you compile it from source.

    Regards

    Regards

    Andutt

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    May 2003
    Posts
    10

    Situation almost under control :-)

    Hello there,

    Thanks for all your inputs. I had made two php pages - namely test.php and tes1.php with the following codes -

    Test.php

    <?
    phpinfo();
    ?>


    Test1.php

    <?php
    phpinfo();
    ?>

    I had placed them in the folder /var/www/html/

    Now when i type the url http://localhost/test.php

    I get a blank page and when I execute http://localhost/test1.php I get the detailed info regarding PHP. Why is this so. What other configurations do I need ? Please suggest.

    Thanks.

  6. #5
    Just Joined!
    Join Date
    May 2003
    Posts
    10
    Hi there,

    That worked. Thanks. Now I need to fix this issue.

    I got a simple site made in PHP and MySQL and is running perfect. I have hosted it locally in Win 98 using PHPTriad. Now when I take the same to the Linux, I get the main page displayed. However when I try to login, nothing happens. I get no errors either. The login details are stored in a config.php file.

    Also after a successful login, I have a script to create the tables for the application. The database has to be created beforehand or can be created through the script itself.

    How do I check whether my PHP is configured for MySQL or not ?

    PS. kindly note that I had installed Apache, PHP and MySQL as available in the packages from the installation disks during the setup itself. I haven't compiled them myself. MySQL is working fine, I say this because I can login to it and create databases and tables.

  7. #6
    Linux Engineer
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    796
    You really shouldnt cross-post topics!!

    Regards
    Regards

    Andutt

  8. #7
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    What kind of login mechanism are you trying to use?

  9. #8
    Just Joined!
    Join Date
    May 2003
    Posts
    10
    Hi there,

    These are the 2 files, one is admin.php and the other vars.php

    admin.php

    Code:
    <?
    	require&#40; "functions.php" &#41;;
    	session_start&#40;&#41;;
    	if&#40; isset&#40; $action &#41; &#41;&#58;
    		if&#40; $action == "logout" &#41;&#58;
    			session_unregister&#40; "name" &#41;;
    			session_unregister&#40; "passwd" &#41;;
    			displayHeader&#40; "Logout" &#41;;
    			echo "
    			<center><h4>You have logout successfully!</h4></center>
    			<p align=center>$homeTitle";
    			displayFooter&#40;&#41;;
    		endif;
    	endif;
    	if&#40; isset&#40; $name &#41; && isset&#40; $passwd &#41; &#41;&#58;
    		if&#40; $name != $adminName || $passwd != $adminPasswd || $name == "" || $passwd == "" &#41;&#58;
    			error&#40; "Invalid username and password" &#41;;
    		elseif&#40; !session_is_registered&#40; "name" &#41; && !session_is_registered&#40; "passwd" &#41;
    		&& $name == $adminName && $passwd == $adminPasswd &#41;&#58;
    			session_register&#40; "name" &#41;;
    			session_register&#40; "passwd" &#41;;
    			displayAdmin&#40;&#41;;
    		elseif&#40; session_is_registered&#40; "name" &#41; && session_is_registered&#40; "passwd" &#41;
    		&& $name == $adminName && $passwd == $adminPasswd &#41;&#58;
    			displayAdmin&#40;&#41;;
    		else&#58;
    			error&#40; "Fatal error, please close your browser and try again!" &#41;;
    		endif;
    	else&#58;
    		displayForm&#40;&#41;;
    	endif;
    	
    	function displayForm&#40;&#41;
    	&#123;
    		displayHeader&#40; "Login in" &#41;;
    		echo "
    		<center><h4>Login in</h4></center>
    		<div align=center>
    		  <center>
    		  <form method=post action=admin.php>
    		  <table border=0 cellpadding=0 cellspacing=0 width=230>
    		    <tr>
    		      <td width=70 height=20>User&#58;</td>
    		      <td width=130 height=20><input type=text name=name size=20 maxlength=10></td>
    		    </tr>
    		    <tr>
    		      <td width=70 height=20>Password&#58;</td>
    		      <td width=130 height=20><input type=password name=passwd size=20 maxlength=10></td>
    		    </tr>
    		    <tr>
    		      <td width=70 height=20></td>
    		      <td width=130 height=20><input type=submit value=\"  Login  \"></td>
    		    </tr>
    		  </table>
    		  </form>
    		  </center>
    		</div>
    		<p align=center><a href=javascript&#58;history.back&#40;&#41;>Back</a></p>";
    		displayFooter&#40;&#41;;
    	&#125;
    	function displayAdmin&#40;&#41;
    	&#123;
    		global $badWordFilter, $banIP;
    		displayHeader&#40; "Admin Area" &#41;;
    		echo "
    		<center><h4>Admin Area</h4></center>
    		<p align=center><a href=delete.php>Delete Message</a></p>
    		<p align=center><a href=filter.php>Bad Words Filter";
    		echo $badWordFilter == 1 ? "&#40;on&#41;" &#58; "&#40;off&#41;";
    		echo"</a></p><p align=center><a href=banip.php>Ban IP";
    		echo $banIP == 1 ? "&#40;on&#41;" &#58; "&#40;off&#41;";
    		echo "</a></p>
    		<p align=center><a href=createdb.php>Create Database</a></p>
    		<p align=center><a href=dropdb.php>Drop Database</a></p>
    		<p align=center><a href=forum.php>Thread Index</p>";
    		displayFooter&#40;&#41;;
    	&#125;
    ?>

    vars.php

    Code:
    <?
    
    	$forumTitle = "Discussion Forum";                            // Forum title
    	$homeTitle = "MyForums.com";                                 // Homepage name
    	$homeURL = "http&#58;//localhost/forum/forum.php";                       // Homepage URL
    	$replyURL = "http&#58;//localhost/forum/reply.php";      // URL to 'reply.php' file
    
    	$dbHost = "localhost";       // MySql host name
    	$dbName = "forum";           // Database name
    	$dbUser = "hello";           // User name
    	$dbPasswd = "hello";          // Password
    
    	$adminName = "admin";        // Admin name
    	$adminPasswd = "admin";      // Password, please change them
    
    	$badWordFilter = 1;         // allow bad words checking? 1=yes, 0=no
    	$banIP = 1;		            // ban ip? 1=yes, 0=no
    	$emailAdmin = 1;            // sent new posting to admin? 1=yes, 0=no
    	$adminEmail = "kaustav11@yahoo.com"; // email address where new posting sent to
    
    	$maxThread = "20";           // Thread number per page
    	$fontFamily = "Verdana";
    	$fontSize = "9pt";
    	$linkColor = "#0080C0";
    	$visitedColor = "#0080C0";
    	$hoverColor = "#0080C0";
    	$bgColor = "#FFFFFF";      // background color
    	$bgImage = "";		   // background image
    ?>
    [/code]

  10. #9
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    What is PHPTriad? Anyway, I can't see anything without the functions.php file that is included by admin.php. The most probable error seems to be that cookies are disabled in your browser, though.

  11. #10
    Just Joined!
    Join Date
    May 2003
    Posts
    10
    Hello there,

    PhpTriad is setup name for phpMyAdmin ( www.phpmyadmin.net ).


    The code for functions.php is -

    Code:
    <?
    require&#40; "vars.php" &#41;;
    function dbConnect&#40;&#41;
    &#123;
    	global $dbHost, $dbUser, $dbPasswd, $dbName;
    	@mysql_connect&#40; $dbHost, $dbUser, $dbPasswd &#41; or error&#40; mysql_error&#40;&#41; &#41;;
    	mysql_select_db&#40; $dbName &#41;;
    &#125;
    function displayHeader&#40; $title &#41;
    &#123;
    	global $fontFamily, $fontSize, $visitedColor, $hoverColor, $linkColor, $forumTitle, $bgColor, $bgImage;
       	echo "
    
    	<html>
    	<head>
    	<title>$title</title>
    	<style type=\"text/css\">
    	<!--
    		body, table &#123; font-family&#58; $fontFamily; font-size&#58; $fontSize; line-height&#58; 1.5 &#125;
    		A&#58;link &#123; color&#58; $linkColor; text-decoration&#58; underline &#125;
    		A&#58;visited &#123; color&#58; $visitedColor; text-decoration&#58; underline &#125;
    		A&#58;hover &#123; color&#58; $hoverColor; text-decoration&#58; none &#125;
    		A&#58;active &#123; color&#58; $linkColor; text-decoration&#58; underline &#125;
    	-->
    	</style>
    	</head>
    	<body bgcolor=$bgColor background=$bgImage>
    	<center><h2><font face = 'Comic Sans Ms' size=6 color=#FF6600>$forumTitle</font></h2></center>
    
    	";
    &#125;
    function displayFooter&#40;&#41;
    &#123;
    	/* Please do not remove or change the code below */
    	echo "
    	<p align=center></p>
    	<p align=center>All Rights Reserved by <a href=http&#58;//localhost/forum/forum.php>myforum.com</a> 2003.</p>
    	
    
    </p>
    	</body>
    	</html>";
    	/* Please do not remove or change the code above */
    	exit;
    &#125;
    function error&#40; $error &#41;
    &#123;
    	global $forumTitle;
    	displayHeader&#40; "Error Page" &#41;;
    	echo "
    	<center><h4>&lt;Error Page&gt;</h4></center>
    	<center><h4><font color=#FF0000>Error&#58; $error</font></h4></center>
    	<p align=center>$forumTitle</p>";
    	displayFooter&#40;&#41;;
    	exit;
    &#125;
    ?>
    Thanks.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •