Jump to content

porting from windows to linux


toovey

Recommended Posts

Hello board,

 

I am porting an existing php web application from Windows to Linux. The application uses mysql, and does not appear to depend on any libraries.  Between the two servers, there does not appear to be any major differences between php configuration paramaters.

 

So the index.php file has some includes, and those files also have includes.  One of them is the mysql username and password information.  Another file contains a function.

 

So when I call index.php, it gives warnings on failures to connect to mysql with the username of apache and no password (I am assuming this is the system default, so the include containing the username and pass isnt working.) Also there is a failure because it tries to call the function that I mentioned previously but it can't find it (says undefined function).

 

In the PHP log file, there are no failures on the includes.  I changed them to requires just to make sure. So assuming that the requires are working properly (safe to assume), then there must be something wrong with my variable scoping and / or function definition scoping???

 

Is there any significant difference between win32 and linux that I should know about?  Is there any articles I can be pointed to?

 

Thanks in advance for your reponses.

 

Brian

Link to comment
Share on other sites

Check the mysql username/password combination.  Double check that, if you are using "localhost", it depends on the server that is running it.  If mysql is on the same system then "localhost" generally works.  If it's in an entirely different area all together normally you have to put the actual information in, instead.

 

Link to comment
Share on other sites

Yea - I imported the mysql database from the win box to the linux box.  I set the mysql authentication information in the config file containing it.  The issue is that the php program is never including these values, as it tries with the account "apache" with no username, which I am assuming is the default.

Link to comment
Share on other sites

The "default" usename (the one it starts with) for mysql is "root".  Try changing your username (in the php script) to root.  If not then show up your

  • login script (username/password blanked out)
  • Your webhost (who is it, what is it)
  • Version of php/mysql/apache

With that we can help you narrow down the problem further from there.

Link to comment
Share on other sites

It sounds like what you were saying is the includes aren't working, or variables aren't passing through all of them. Are you using require() instead of include()? Try that first.

Then make sure in any functions the variables are marked global.

Link to comment
Share on other sites

"I imported the mysql database from the win box to the linux box."

 

It depends on your definition of import.  If you went into phpMyAdmin, picked a database, and created a .sql (or .zip) which you then imported into the linux machine via it's phpMyAdmin, then the user privileges for the MySQL server are not intact.

 

Is this linux box provided via a hosting company?  If it is, then the e-mail they sent you when you signed up for their hosting will contain the host, user, and password information for the MySQL server.

Link to comment
Share on other sites

This is the start of my script:

 

<?      require("connect.php");

        require("include/functions.php");

        $today=gmdate("Y-m-d");

 

        $squery="DELETE FROM ticket_bid WHERE expirydate < '$today'";

        $sresult=mysql_query($squery);

 

 

 

 

connect.php contains the following:

<?

session_start();

require ("include/config.inc.php");

//include_once ("include/functions.php");

include_once("include/CryToGraphy.php");

//="http://com22/tixstopsite/";

error_reporting(7);

include "include/debug.php";

 

require ("include/new_connect.inc.php");

 

 

$db=mysql_connect($DBSERVER, $USERNAME, $PASSWORD);

mysql_select_db($DATABASENAME,$db);

mysql_query("delete from tickets  where quantity < 1");

echo mysql_error();

 

 

 

 

include/config.inc.php contains the following:

 

        $DBSERVER = "127.0.0.1";

        $DATABASENAME = "somedb";

        $USERNAME = "root";

        $PASSWORD = "password";

 

 

 

 

include/new_connect.inc.php

 

<?

function p_r($arr) {

if (debug) {echo "<pre>";

print_r($arr);

echo "</pre>";}

}

/* new connect*/

$config['dbname']=$DATABASENAME;

$config['persistent']=0;

$_host=$GLOBALS[_SERVER][HTTP_HOST];

p_r($_host);

  include("mysql.inc.php");

  $dbh = new sql;

  $host_arr=array(

 

  'localhost'=>array(connect=>array($DBSERVER, $USERNAME, $PASSWORD,$USERNAME), title=>'DEV')

 

  );

p_r($host_arr);

 

$dbh -> connect('mysql', $host_arr[$_host][connect]);

 

//p_r($dbh); exit;

?>

 

 

My log is as follows:

[client 63.118.15.152] PHP Warning:  mysql_connect(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 29

[client 63.118.15.152] PHP Warning:  mysql_list_tables(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 31

[client 63.118.15.152] PHP Warning:  mysql_list_tables(): A link to the server could not be established in /var/www/seatline1/include/mysql.inc.php on line 31

[client 63.118.15.152] PHP Warning:  mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /var/www/seatline1/include/mysql.inc.php on line 41

[client 63.118.15.152] PHP Fatal error:  Call to undefined function:  find_environmental() in /var/www/seatline1/include/mysql.inc.php on line 310

Link to comment
Share on other sites

register_globals being off requires that in order to use a variable which is defined outside of a function, you must mark it global in the function.

 

That has nothing to do with register_globals I'm sorry. If register globals was of on windows, leave it off in Linux. It is to do with ENV, GET, POST, COOKIE, and SERVER all becomig global instead of being contained within there allocated arrays.

 

The problem does indeed appear to be with your includes. What are the file permissions of them?

Link to comment
Share on other sites

There in different subdirectories - posting them in the forum will be huge - its 8600 hundred lines

 

here are the individual files:

[root@sls-cd1p1 hotel]# ls -lah /var/www/seatline1/ |grep index.php

-rw-r--r--  1 root root  12K Feb  7 08:18 index.php

 

here is connect.php

[tt]-rw-r--r--  1 root root 3.8K Feb  7 07:40 connect.php,/tt]

 

and here is the include directory:

[root@sls-cd1p1 seatline1]# ls -lah /var/www/seatline1/include

total 180K

drwxr-xr-x  2 root root 4.0K Feb  7 17:48 .

drwxr-xr-x  24 root root 4.0K Feb  8 11:58 ..

-rw-r--r--  1 root root 2.3K Aug 13 20:37 calendar.inc.php

-rw-r--r--  1 root root 4.3K Apr  6  2006 common.js

-rw-r--r--  1 root root  951 Feb  6 22:49 config.inc.php

-rw-r--r--  1 root root  11K Apr  6  2006 creditcard.js

-rw-r--r--  1 root root  940 Apr  6  2006 CryToGraphy.php

-rw-r--r--  1 root root  26 Aug  6  2006 debug.php

-rw-r--r--  1 root root  12K Jul 30  2006 functions.php

-rw-r--r--  1 root root  207 Apr  6  2006 imageprocess.php

-rw-r--r--  1 root root  73 Apr  6  2006 index.php

-rw-r--r--  1 root root 1.8K Jul  6  2006 mailfunctions.php

-rw-r--r--  1 root root  12K Aug  6  2006 mysql.inc.php

-rw-r--r--  1 root root 1.6K Feb  6 19:22 new_connect.inc.php

-rw-r--r--  1 root root 2.6K Apr  6  2006 resize1.php

-rw-r--r--  1 root root 3.9K Apr  6  2006 resize.php

-rw-r--r--  1 root root  720 Apr  6  2006 safecode.php

-rw-r--r--  1 root root  613 Apr  6  2006 sendmail.php

-rw-r--r--  1 root root 4.0K Jun  6  2006 timedate.php

Link to comment
Share on other sites

[root@sls-cd1p1 www]# chown -R apache /var/www/seatline1

 

Same errors:

 

[client 63.118.15.152] PHP Warning:  mysql_connect(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 29

[client 63.118.15.152] PHP Warning:  mysql_list_tables(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/seatline1/include/mysql.inc.php on line 31

[client 63.118.15.152] PHP Warning:  mysql_list_tables(): A link to the server could not be established in /var/www/seatline1/include/mysql.inc.php on line 31

[client 63.118.15.152] PHP Warning:  mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /var/www/seatline1/include/mysql.inc.php on line 41

[client 63.118.15.152] PHP Fatal error:  Call to undefined function:  find_environmental() in /var/www/seatline1/include/mysql.inc.php on line 310

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.