LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-31-2011, 02:42 PM   #1
rlestage
LQ Newbie
 
Registered: Jan 2011
Posts: 25

Rep: Reputation: 0
Apache 2.0 - Migrating to new server


Hi Guys,

At my company, When I came in...one of the servers is a small webserver that just hosts our website, it used to host a scalix e-mail server but I've since moved to Google Apps.

Anyways, I've been slowly converting the servers to VMware, I'm onto the Webserver now.

I am Running CentOS5.5, I've installed the new server on the VMware client.

What I don't know how to do is copy the apache 2.0 server (which files,commands,etc) over to the new one so that I can start to run the web server from the VM.

Thanks, help is much appreciated
 
Old 01-31-2011, 02:47 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
*Generally* speaking, the default website path for Centos is /var/www/

So, *generally*, you can take whatever is in /var/www/ and (copy) it to /var/www/ on the new server, and everything will be just fine.

This is ignoring any Mysql database configurations, or database schema, special settings in /etc/httpd/ and /etc/php.ini and /etc/php.d.
 
Old 01-31-2011, 03:33 PM   #3
rlestage
LQ Newbie
 
Registered: Jan 2011
Posts: 25

Original Poster
Rep: Reputation: 0
Alright, I will try that.

Also, I do know that to get the website to work, I do have to type /etc/init.d/mysqld start
Does that my I have mysqul database configs as well that need to be transferred? I know the website is in PHP, our webmaster has done it all with that. So I just set up an FTP for him to login to the admin folder to do any of his uploads.
 
Old 02-01-2011, 01:43 PM   #4
rlestage
LQ Newbie
 
Registered: Jan 2011
Posts: 25

Original Poster
Rep: Reputation: 0
Ok So obviously no go.

I've been doing reading,and what I have to do is backup my MySQL & PHP Databases. I'm not quite sure how to go about this?
 
Old 02-01-2011, 01:53 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
I better get some repuation points for this

Please read through the explanations before doing any of these steps.

This is a mysql function that will pull out the user names, passwords and all related user settings from a Mysql database. The usage of this, would be to grab any specialized users for the application, and move them and their passwords and permissions to a new mysql database.

Code:
mygrants() {
	# Displays all grant information
        # Usage: mygrants [-h -u -p]
        mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
        'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
        ) AS query FROM mysql.user" |   mysql $@ |   sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'; }

# Once you copy and paste this into a terminal, simply type 'mygrants'
Now that you have your mysql users, we have to grab the databases in mysql and move them else where. This script will output (dump) all databases to sql files that can be copied to another location and imported. Only import the ones to do with your application,.. I would NOT suggest importing mysql.sql.

Code:
# Get database names
                databases="$($mysql -u $muser -h $mhost -p$mpass -Bse 'show databases')"

                # Get database dumps
                        mkdir /root/database_backup
                        for db in $databases
                                do
                                $mysqldump --routines --complete-insert --single-transaction --quick -u $muser -h $mhost -p$mpass $db > /root/database_backup/$db.sql
                                $md5sum /root/database_backup/$db.sql > /root/database_backup/$db.sql.md5
                                done
Then grab a copy of your website:

Code:
cd /root;
tar czvf website-backup.tar.gz /var/www
After doing these 3 steps you will have 3 things:

1) A user list that can be inserted into a new mysql db (Copy and paste output of mygrants into new database)
2) Database dumps that can be imported into a new mysql db (Use 'mysql' to import the dumps)
3) A backup of your website that can be unzipped to a new server (Copy it to the new server, untar it, move it to the correct place)

Last edited by szboardstretcher; 02-01-2011 at 01:55 PM.
 
Old 02-01-2011, 03:29 PM   #6
rlestage
LQ Newbie
 
Registered: Jan 2011
Posts: 25

Original Poster
Rep: Reputation: 0
I shall get started on this.

One question, The first part that I copy and paste. Where is the output of all this? Is there something I'm supposed to copy to move to the new server?

Thanks, sorry for sounding like a newb...but I am
 
Old 02-01-2011, 03:32 PM   #7
rlestage
LQ Newbie
 
Registered: Jan 2011
Posts: 25

Original Poster
Rep: Reputation: 0
I got an error (of course I did) when I copied the first part, and then typed mygrants.

" ERROR 1045 (28000) Access denied for user ' root'@'localhost' (using password: NO)
 
Old 02-01-2011, 03:32 PM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
Originally Posted by rlestage View Post
I shall get started on this.

One question, The first part that I copy and paste. Where is the output of all this? Is there something I'm supposed to copy to move to the new server?

Thanks, sorry for sounding like a newb...but I am
When you run the 'mygrants' function, it will output a lot of stuff. Grab anything relating to your Webuser, like "phpadmin" or "phpuser" or whatever, and paste it into your new mysql instance. Obviously, you do not want to grab usernames and passwords that you do not intend on using.

Click 'yes' on the bottom right of my post if you found my post helpful.
 
Old 02-01-2011, 03:35 PM   #9
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
Originally Posted by rlestage View Post
I got an error (of course I did) when I copied the first part, and then typed mygrants.

" ERROR 1045 (28000) Access denied for user ' root'@'localhost' (using password: NO)
Code:
mygrants -u username -p password
you can fill in those parameters with yours.
 
Old 02-02-2011, 11:59 AM   #10
rlestage
LQ Newbie
 
Registered: Jan 2011
Posts: 25

Original Poster
Rep: Reputation: 0
When I fill in those parameters...I get this output

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I'm not sure what username and password i'm supposed to put there. Just incase I tried both root with the root password. I also tried the username mysql with its associated password.
 
Old 02-02-2011, 07:04 PM   #11
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
Typically that error means that there is no mysql server listening for connections. Are you running the commands on the server that has MySQL or on a separate host? Also make sure that the mysql process is running and that it is listening (port 3306)

If you type
Code:
ps aux | grep mysql
you should see multiple lines including something like
Code:
mysql     1573  0.1  0.9 245640 26948 ? Sl   Jan23  16:15 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
Similarly,
Code:
netstat -ntap
should give you something like
Code:
tcp        0      0 0.0.0.0:3306            0.0.0.0:*   LISTEN   1573/mysqld
These lines show that the mysql daemon is running, is bound to the socket /var/run/mysqld/mysqld.sock and listening for tcp connections on port 3306.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Migrating from one server to another abharsair Linux - Server 11 03-11-2009 03:25 PM
Migrating a server sharptech Fedora 8 04-03-2007 11:51 AM
Migrating Apache 1.3 configuration files to Apache 2 kaplan71 Linux - Software 0 03-28-2007 11:05 AM
Migrating Windows Email Server to Linux Server fredidehen Linux - Newbie 3 09-05-2006 09:18 PM
Beginners Only! PostGreSQL, PHP, Apache and RedHat 9.0 ! (migrating from windows2k) scorpatron LinuxQuestions.org Member Success Stories 3 11-14-2003 10:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration