setup web server centos with apache

Install Apache, Mysql , PhP Web Server

# yum install httpd mod_ssl

#/etc/init.d/httpd start

# yum install mysql mysql-server

# chkconfig –levels 235 mysqld on
# /etc/init.d/mysqld start

configure mysql

Set the MySQL service to start on boot
chkconfig –levels 235 mysqld on
Start the MySQL service
service mysqld start
Log into MySQL
mysql -u root
Set the root user password for all local domains
SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘new-password‘);
SET PASSWORD FOR ‘root’@’localhost.localdomain’ = PASSWORD(‘new-password‘);
SET PASSWORD FOR ‘root’@’127.0.0.1′ = PASSWORD(‘new-password‘);
Drop the Any user
DROP USER ”@’localhost’;
DROP USER ”@’localhost.localdomain’;
Exit MySQL
exit

 

php53-common conflicts with php-common

php53-common-5.3.3-13.el5_8.x86_64 from installed has depsolving problems
–> php53-common conflicts with php-common
Error: php53-common conflicts with php-common

 

This issue normally happens when you have upgraded your PHP to new version 5.3 and try to install a old extension

Solution:  find the extension which in the same version or install extension from source file

 

php-tips-insert-href-link-in-a-php-code

If the link needs to be inside of the PHP you have two options. Option one is to end the PHP and then reopen it. Here is an example:
<?php
—– My PHP Code—-
?>
<a href=”https://twitter.com/angela_bradley”>My Twitter</a>
<?php
—– My PHP Code—-
?>

The other option is to print or echo the HTML code inside of the PHP. Here is an example:
<?php
Echo “<a href=https://twitter.com/angela_bradley>My Twitter</a>”
?>

html-tip-using-quotes-in-form-input-tags

In (X)HTML, attribute values should be enclosed by double or single quotes. But a common source of errors and confusion arises when those values themselves contain double or single quotes. This is especially common for form input fields, where the values might contain data obtained from a database or supplied previously by the user.

Yes, using &quot; works:

<input type="text" name="last_name" value="&quot;My quote!&quot;" />


but another fix is using PhP - i found this with google search

Consider the case of an input text field for last name:

<input type=’text’ name=’last_name’ value=” />

Usually, attribute values are surrounded by double quotes, but single quotes are also allowed, and serve to highlight the pitfall here. Say that the value of the last name text field is taken from a database of users, and this particular user’s last name is “O’Reilly” – the PHP code will be:

<input type=’text’ name=’last_name’ value='<?php print $lastName; ?>’ />

And the HTML output will be:

<input type=’text’ name=’last_name’ value=’O’Reilly’ />

This will make the last name appear as just “0” in a browser, and will be sent as that when submitting the form. This is because the single quote in “O’Reilly” is taken as marking the end of the value. What we want is to encode the quote character so that HTML understands what we mean is the literal character for a single quote. The encoded version of a single quote is “&#39;”. The encoding can be done in a number of ways. For example, we can use the function str_replace() to replace all occurrences of “‘” with “&#39;”. But the most convenient and complete way is to use thehtmlentities() function on the $lastName variable, as in the following PHP code:

<input type=’text’ name=’last_name’ value='<?php print htmlentities($lastName, ENT_QUOTES); ?>’ />

Which will output:

<input type=’text’ name=’last_name’ value=’O&#39;Reilly’ />

Although “O’Reilly” is now not in its literal form in the HTML code, it will be displayed and sent properly from a form on an HTML page as seen in a browser.



Display & Save Visitor’s Ip – PHP Code

found a blog post which tested and working very good

PHP-Hypertext Preprocessor.
PHP is a server side script language.Using php you can create a dynamic websites.
This is the first lesson and on this lesson you will learn how to get visitors ip and save it on your server.(i wil learn you how add this to your blog  or any web sites that haven’t php.)
-Display User’s informations-

<?php
$ip = $_SERVER[‘REMOTE_ADDR’];
$hostaddress = gethostbyaddr($ip);
$browser = $_SERVER[‘HTTP_USER_AGENT’];
$referred = $_SERVER[‘HTTP_REFERER’]; // a quirky spelling mistake that stuck in php

print “<strong>Display IP address:</strong><br />\n”;
print “$ip<br /><br />\n”;
print “<strong>More detailed host address:</strong><br />\n”;
print “$hostaddress<br /><br />\n”;
print “<strong>Display browser info</strong>:<br />\n”;
print “$browser<br /><br />\n”;
print “<strong>Where you came from (if you clicked on a link to get here</strong>:<br />\n”;
if ($referred == “”) {
print “Page was directly requested”;
}
else {
print “$referred”;
}
?>
-Code Descriptions-
<?php -to start php file.
$ip – give a variable  name to $_SERVER[‘REMOTE_ADDR’] (like y=mx+c).
$_SERVER[‘REMOTE_ADDR’]-this is the code that get user ip.
gethostbyaddr($ip) -to get host name.
$_SERVER[‘HTTP_USER_AGENT’]-get browser information.
$_SERVER[‘HTTP_REFERER’]-get where user come from.
//-we use this to put a comment in our php file.// for 1 line comment.
/*-this is for long comment and end with */
print”what you want to display on the page“;-we use this to display something on the page.
<br>-this is for line break .when we use this code.the text after this code will display in next line.

How i save user’s Informations ??

<?php

$myFile = “countip.mic”;

$fh = fopen($myFile, ‘a+’) or die(“can’t open file”);

$stringData =”Date:”.date(‘Y-m-d H:i:s’).”<br/>Ip:”.$_SERVER[‘REMOTE_ADDR’].”<br/>Browser:”.$_SERVER[‘HTTP_USER_AGENT’].”<br/>\n” ;

fwrite($fh, $stringData);

fclose($fh);
?>

-Code Descriptions-
$myfile=”countip.mic”; -$myfile is the variable that for “countip.mic”.
fwrite($fh,$stringData); -do that discribe on $fh variable and $stringData .(create countip.mic file and save data).
fclose($fh);-close the file that we open.
we get the date  time to countip file using .date(‘Y-m-d H:i:s).code.

Code for Display user’s information and Save(broth in one file) .

 

 

<?php
$ip = $_SERVER[‘REMOTE_ADDR’];
$hostaddress = gethostbyaddr($ip);
$browser = $_SERVER[‘HTTP_USER_AGENT’];
$referred = $_SERVER[‘HTTP_REFERER’]; // a quirky spelling mistake that stuck in php

print “<strong>Display IP address:</strong><br />\n”;
print “$ip<br /><br />\n”;
print “<strong>More detailed host address:</strong><br />\n”;
print “$hostaddress<br /><br />\n”;
print “<strong>Display browser info</strong>:<br />\n”;
print “$browser<br /><br />\n”;
print “<strong>Where you came from (if you clicked on a link to get here</strong>:<br />\n”;
if ($referred == “”) {
print “Page was directly requested”;
}
else {
print “$referred”;
}
?>
<?php

$myFile = “countip.mic”;

$fh = fopen($myFile, ‘a+’) or die(“can’t open file”);

$stringData =Date:”.date(‘Y-m-d H:i:s’).”<br/>Ip:”.$_SERVER[‘REMOTE_ADDR’].”<br/>Browser:”.$_SERVER[‘HTTP_USER_AGENT’].”<br/>\n” ;

fwrite($fh, $stringData);

fclose($fh);
?>

 

 

 

 

 

 

 
How I put this code to my website ??
First i will learn you how to add this code to your hosting that php working.

When you add this php codes to your blog or web site you must have another hosting that  php working.Many hosting providers give free php working accounts.
First you must get a free hosting account.
(click here to google search about free accounts.then select one and Register on it(eg:www.000webhost.com )).

1.Create file on your desktop with .php extension (eg:countip.php)  .
2.Copy the code and paste it on your file.
3.Save it and Upload it(your file) to you hosting account.
To download php zip file click here.(extract zip fle and upload it)
(To Upload Your file to your hosting account  .you can use Filezilla software).
Then go to your file (after you upload it) using a browser.You can see your informations on your page.
Click here to see preview. And click here to see the save file on the server.

 

Coutesy: http://webdevelopstepbystep.blogspot.com/2011/08/display-save-visitors-ip-php-code-1.html

WP Twitter Auto Publish Powered By : XYZScripts.com