centos
login with su
and type bellow command
# yum --enablerepo=centosplus install php-xml
Freelance Web Programmer, Android, Php 5, java, MySql, JQuery, Symfony framework, Smarty template, facebook application, googlemap application
Friday, November 4, 2011
Tuesday, October 4, 2011
mssql server conncet to linux php
now install in linux machine(fedora/centos)
yum install freetds
and
yum install php-mssql (if not work then go menu system -> administartor add/remove software and search mssql and select php-mssql)
open
/etc/freetdsconf
and add the last
[conncetmssql]
host = 192.168.1.5
port = 1433
tds version = 4.2
> service httpd restart
example:
<?php
if (function_exists('mssql_connect')){
echo "Okay, function work";
} else {
echo "php-mssql not installed";
}
if(extension_loaded("mssql")) {
echo "MSSQL is Loaded<br>";
}
else {
echo "MSSQL not loaded<br>";
}
// Connecting, selecting database
$link = mssql_connect('conncetmssql', 'username', 'password') or die('Could not connect: ' . mssql_get_last_message());
echo 'Connected successfully';
mssql_select_db('yourdatabasename') or die('Could not select database');
echo "select db";
// Performing SQL query
$query = 'SELECT * FROM tablename';
$result = mssql_query($query) or die('Query failed: ' . mssql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mssql_fetch_array($result, MSSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mssql_free_result($result);
// Closing connection
mssql_close($link);
?>
Configure a server alias to use TCP/IP sockets
Note To configure a server alias to use TCP/IP sockets, you must provide the server name and the TCP/IP port number.
1. Determine the TCP/IP port number of the instance of SQL Server.
SQL Server 2005
1. Open SQL Server Configuration Manager, and then expand SQL Server 2005 Network Configuration.
2. Click Protocols for InstanceName, and then double-click TCP/IP in the right panel.
Note InstanceName is a placeholder for the named instance of SQL Server 2005.
3. On the Protocol tab, notice the value of the Listen All item.
4. Click the IP Addresses tab:
* If the value of Listen All is yes, the TCP/IP port number for this instance of SQL Server 2005 is the value of the TCP Dynamic Ports item under IPAll.
* If the value of Listen All is no, the TCP/IP port number for this instance of SQL Server 2005 is the value of the TCP Dynamic Ports item for a specific IP address.
Note If the value of the TCP Dynamic Ports item is not set, you must set it yourself. For more information about how to configure a server to listen on a specific TCP port, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn2.microsoft.com/en-us/library/ms177440.aspx (http://msdn2.microsoft.com/en-us/library/ms177440.aspx)
5. Click OK.
or more detail bellow two link
1. http://support.microsoft.com/kb/265808
2. http://msdn.microsoft.com/en-us/library/ms177440.aspx
yum install freetds
and
yum install php-mssql (if not work then go menu system -> administartor add/remove software and search mssql and select php-mssql)
open
/etc/freetdsconf
and add the last
[conncetmssql]
host = 192.168.1.5
port = 1433
tds version = 4.2
> service httpd restart
example:
<?php
if (function_exists('mssql_connect')){
echo "Okay, function work";
} else {
echo "php-mssql not installed";
}
if(extension_loaded("mssql")) {
echo "MSSQL is Loaded<br>";
}
else {
echo "MSSQL not loaded<br>";
}
// Connecting, selecting database
$link = mssql_connect('conncetmssql', 'username', 'password') or die('Could not connect: ' . mssql_get_last_message());
echo 'Connected successfully';
mssql_select_db('yourdatabasename') or die('Could not select database');
echo "select db";
// Performing SQL query
$query = 'SELECT * FROM tablename';
$result = mssql_query($query) or die('Query failed: ' . mssql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mssql_fetch_array($result, MSSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mssql_free_result($result);
// Closing connection
mssql_close($link);
?>
Configure a server alias to use TCP/IP sockets
Note To configure a server alias to use TCP/IP sockets, you must provide the server name and the TCP/IP port number.
1. Determine the TCP/IP port number of the instance of SQL Server.
SQL Server 2005
1. Open SQL Server Configuration Manager, and then expand SQL Server 2005 Network Configuration.
2. Click Protocols for InstanceName, and then double-click TCP/IP in the right panel.
Note InstanceName is a placeholder for the named instance of SQL Server 2005.
3. On the Protocol tab, notice the value of the Listen All item.
4. Click the IP Addresses tab:
* If the value of Listen All is yes, the TCP/IP port number for this instance of SQL Server 2005 is the value of the TCP Dynamic Ports item under IPAll.
* If the value of Listen All is no, the TCP/IP port number for this instance of SQL Server 2005 is the value of the TCP Dynamic Ports item for a specific IP address.
Note If the value of the TCP Dynamic Ports item is not set, you must set it yourself. For more information about how to configure a server to listen on a specific TCP port, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn2.microsoft.com/en-us/library/ms177440.aspx (http://msdn2.microsoft.com/en-us/library/ms177440.aspx)
5. Click OK.
or more detail bellow two link
1. http://support.microsoft.com/kb/265808
2. http://msdn.microsoft.com/en-us/library/ms177440.aspx
Monday, August 8, 2011
Connection could not be established with host localhost
Connection could not be established with host localhost [permission denied]
in Linux
send mail in php
send mail from Swift_TransportException
check php.ini
SMTP localhost
smtp_port 25
sendmail_from no value
sendmail_path /usr/sbin/sendmail -t -i
sendmail service start and enabled
in firewall
Mail(SMTP) 25/tcp
SELinux
system default enforcing mode : Disabled
in Linux
send mail in php
send mail from Swift_TransportException
check php.ini
SMTP localhost
smtp_port 25
sendmail_from no value
sendmail_path /usr/sbin/sendmail -t -i
sendmail service start and enabled
in firewall
Mail(SMTP) 25/tcp
SELinux
system default enforcing mode : Disabled
Saturday, August 6, 2011
how to make jar file
make jar file
jar cvfm MyJarName.jar manifest.txt *.class *.txt
in manifest.txt
Main-Class: ExecuteclassName
runjar file
java -jar MyJarName.jar
jar file execute on click
right click on jar file and open with path to jre/lib/jexec
jar cvfm MyJarName.jar manifest.txt *.class *.txt
in manifest.txt
Main-Class: ExecuteclassName
runjar file
java -jar MyJarName.jar
jar file execute on click
right click on jar file and open with path to jre/lib/jexec
Start rmiregistry programmatically
try {
LocateRegistry.createRegistry(1099);
} catch (RemoteException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
LocateRegistry.createRegistry(1099);
} catch (RemoteException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Tuesday, June 28, 2011
Apache Userdir enabled
go to
In httpd.conf
add comment bellow line
userdir disabled
-----------------------------------------------
chmod 711 for /home/userdir(userid)
chmod 755 for /home/userdir(userid)/public_html
[or]
chcon -R -t htppd_sys_content_t /home/keval/web
-----------------------------------------------
system => selinux management => boolean
check => Allow httpdto read home directores(module apache)
[or]
setsebool -P httpd_enable_homedirs true
-----------------------------------------------
remove comment in httpd.conf
NameVirtualHost *:80
ServerName localhost
DocumentRoot /home/userdir/web
-----------------------------------------------
restart httpd
-----------------------------------------------
/etc/hosts
change localhost localhost.localdomain to localhost.localdomain localhost
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
replace with
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
-----------------------------------------------
In httpd.conf
add comment bellow line
userdir disabled
-----------------------------------------------
chmod 711 for /home/userdir(userid)
chmod 755 for /home/userdir(userid)/public_html
[or]
chcon -R -t htppd_sys_content_t /home/keval/web
-----------------------------------------------
system => selinux management => boolean
check => Allow httpdto read home directores(module apache)
[or]
setsebool -P httpd_enable_homedirs true
-----------------------------------------------
remove comment in httpd.conf
NameVirtualHost *:80
ServerName localhost
DocumentRoot /home/userdir/web
-----------------------------------------------
restart httpd
-----------------------------------------------
/etc/hosts
change localhost localhost.localdomain to localhost.localdomain localhost
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
replace with
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
-----------------------------------------------
Friday, May 27, 2011
How to recover / change the root password on RedHat Linux based systems
How to recover / change the root password on RedHat Linux based systems
Power on, or reboot as needed.
and press 'tab' key
Now you should press 'e' and you will get this screen.
plz select kernel option
now press 'e'
Insert an space and the number one '1'.
After that press ENTER and 'b' and ENTER again.
Now you can change the password like this
#passwd
enter new password
then
give
#chmod u+s /bin/su
and
#exit
Power on, or reboot as needed.
and press 'tab' key
Now you should press 'e' and you will get this screen.
plz select kernel option
now press 'e'
Insert an space and the number one '1'.
After that press ENTER and 'b' and ENTER again.
Now you can change the password like this
#passwd
enter new password
then
give
#chmod u+s /bin/su
and
#exit
Tuesday, April 19, 2011
Enable Remote Access To Mysql Database Server
By default remote access to MySQL database server is disabled for security reasons. However, some time you need to provide remote access to database server from home or a web server.
Working on fedora 10, php 5.3.2 and mysql Server version: 5.1.47
Edit my.cnf File
Red Hat Linux/Fedora/Centos Linux file is located at /etc/my.cnf location
opne this file and search [mysqld]
and add bellow line
port = 3306
bind-address = your system ip
service mysqld restart
Open port 3306
open TCP port 3306 using iptables.
A sample iptables rule to open Linux iptables firewall
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
save all rules
service iptables save
Example
<?php
$link = mysql_connect('host ip', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
exit;
}
$db_selected = mysql_select_db('database',$link);
if (!$db_selected) {
die ('Can\'t use database : ' . mysql_error());
exit;
}
$sql = "SELECT id as col1, col2, col3 FROM sometable";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row["col1"];
echo " ".$row["col2"];
echo " ".$row["col3"];
}
mysql_free_result($result);
mysql_close($link);
?>
Base on : http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Working on fedora 10, php 5.3.2 and mysql Server version: 5.1.47
Edit my.cnf File
Red Hat Linux/Fedora/Centos Linux file is located at /etc/my.cnf location
opne this file and search [mysqld]
and add bellow line
port = 3306
bind-address = your system ip
service mysqld restart
Open port 3306
open TCP port 3306 using iptables.
A sample iptables rule to open Linux iptables firewall
/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
save all rules
service iptables save
Example
<?php
$link = mysql_connect('host ip', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
exit;
}
$db_selected = mysql_select_db('database',$link);
if (!$db_selected) {
die ('Can\'t use database : ' . mysql_error());
exit;
}
$sql = "SELECT id as col1, col2, col3 FROM sometable";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row["col1"];
echo " ".$row["col2"];
echo " ".$row["col3"];
}
mysql_free_result($result);
mysql_close($link);
?>
Base on : http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Thursday, April 7, 2011
windows desktop corrupted
if windows desktop corrupted
then copy explorer.exe from working windows folder to corrupted deskotp windows folder (same version)
then copy explorer.exe from working windows folder to corrupted deskotp windows folder (same version)
Tuesday, March 8, 2011
mount nfs no route to host
in fedora os
first open
vi /etc/exports
add bellow line
/home/USER_NAME/public_html 192.168.1.*(rw,async,no_root_squash)
exportfs -a -v
service nfs start
chkconfig nfs on
service portmap restart
chkconfig portmap on
service iptables stop
(if you want to iptables service permanently disable)
/sbin/chkconfig iptables off
then after mount nfs from other system bellow command
mount -o rw,async 192.168.1.(server id):/home/USER_NAME/web /home/USERS_NAME/MOUNT_DIR_NAME
auto mount in booting (server dir local sys dir)
192.168.1.1:/home/keval/web /home/keval/kevalweb nfs defaults 0 0
==============================
if ssh login not work on fedora
then try commnad through
passwd username
first open
vi /etc/exports
add bellow line
/home/USER_NAME/public_html 192.168.1.*(rw,async,no_root_squash)
exportfs -a -v
service nfs start
chkconfig nfs on
service portmap restart
chkconfig portmap on
service iptables stop
(if you want to iptables service permanently disable)
/sbin/chkconfig iptables off
then after mount nfs from other system bellow command
mount -o rw,async 192.168.1.(server id):/home/USER_NAME/web /home/USERS_NAME/MOUNT_DIR_NAME
auto mount in booting (server dir local sys dir)
192.168.1.1:/home/keval/web /home/keval/kevalweb nfs defaults 0 0
==============================
if ssh login not work on fedora
then try commnad through
passwd username
Monday, March 7, 2011
mysql data copy
start mysql
> mysql -h localhost -u root -p
create user
mysql> create user 'user_name'@'localhost' identified by 'password';
create database
mysql> create database db_name
use database
mysql> use db_name;
copy data from file
mysql> \. /home/user_name/Downloads/my_db.sql
> mysql -h localhost -u root -p
create user
mysql> create user 'user_name'@'localhost' identified by 'password';
create database
mysql> create database db_name
use database
mysql> use db_name;
copy data from file
mysql> \. /home/user_name/Downloads/my_db.sql
apache virtual host configuration
httpd.conf file setting
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disabled
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html
</IfModule>
make file /etc/httpd/conf.d/vhost.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.test.local
DocumentRoot /home/USER_NAME/public_html/www.test.com
<Directory /home/USER_NAME/public_html/www.test.com>
AllowOverride All
Options FollowSymlinks
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
commond prompt
chcon -R -t htppd_sys_content_t /home//public_html
setsebool -P httpd_enable_homedirs true
/etc/hosts file entry
127.0.0.1 www.test.local
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disabled
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html
</IfModule>
make file /etc/httpd/conf.d/vhost.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.test.local
DocumentRoot /home/USER_NAME/public_html/www.test.com
<Directory /home/USER_NAME/public_html/www.test.com>
AllowOverride All
Options FollowSymlinks
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
commond prompt
chcon -R -t htppd_sys_content_t /home/
setsebool -P httpd_enable_homedirs true
/etc/hosts file entry
127.0.0.1 www.test.local
Friday, February 18, 2011
Facebook app request
how to get facebook apprequest receiver user id
<a onclick="facebook_invitess_users(); return false;" href="#" class="link2">click here</a>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: 'your_appid', status: true, cookie: true, xfbml: true});
};
FB.init({appId: 'your_appid', status: true, cookie: true, xfbml: true});
var facebook_invitess_users = function() {
FB.ui(
{
method: 'apprequests',
message: rebuild,
data: 'tracking information for the user',
title: 'Choose the friends you would like to invite',
},
function(response) {
jQuery.post(
"submit_url",
{request_ids: response.request_ids},
function(data) { alert(data); },
"html"
);
}
);
}
</script>
submit url php file code
<?php
if(isset($_REQUEST['request_ids'])) {
$sent = $_REQUEST['request_ids']; //Convert csv to array
$count = count($sent); //count how many objects in array
$appid = 'facebook_app_id';
$secret = 'facebook_app_secrct';
$app_token = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.$appid.'&client_secret='.$secret.'&grant_type=client_credentials');
//Get application token
for ($a = 0; $a < $count; $a++) {
$request = file_get_contents('https://graph.facebook.com/'.$sent[$a].'?'.$app_token);
print_r($request); // This will output like below
$arr = json_decode($request);
var_dump($arr);
print_r($arr->to->name);
print_r($arr->to->id);
}
}
?>
<a onclick="facebook_invitess_users(); return false;" href="#" class="link2">click here</a>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: 'your_appid', status: true, cookie: true, xfbml: true});
};
FB.init({appId: 'your_appid', status: true, cookie: true, xfbml: true});
var facebook_invitess_users = function() {
FB.ui(
{
method: 'apprequests',
message: rebuild,
data: 'tracking information for the user',
title: 'Choose the friends you would like to invite',
},
function(response) {
jQuery.post(
"submit_url",
{request_ids: response.request_ids},
function(data) { alert(data); },
"html"
);
}
);
}
</script>
submit url php file code
<?php
if(isset($_REQUEST['request_ids'])) {
$sent = $_REQUEST['request_ids']; //Convert csv to array
$count = count($sent); //count how many objects in array
$appid = 'facebook_app_id';
$secret = 'facebook_app_secrct';
$app_token = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.$appid.'&client_secret='.$secret.'&grant_type=client_credentials');
//Get application token
for ($a = 0; $a < $count; $a++) {
$request = file_get_contents('https://graph.facebook.com/'.$sent[$a].'?'.$app_token);
print_r($request); // This will output like below
$arr = json_decode($request);
var_dump($arr);
print_r($arr->to->name);
print_r($arr->to->id);
}
}
?>
Subscribe to:
Posts (Atom)
how to see xml preview in browser php
xml preview view in browser $xml = new DOMDocument('1.0', 'UTF-8'); $xml->preserveWhiteSpace = false; ...
-
Weather In Summer: 33.8 C (Max) - 23.3 C (Min) In winter: 20.3 C (Max) - 0 C (Min) Rainy Season : from July to Mid Sept, and very humid (Upt...
-
go to In httpd.conf add comment bellow line userdir disabled ----------------------------------------------- chmod 711 for /home/userdir(use...
-
The contents of my /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX=permissive # enforcing - ...