Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-31-2011, 02:42 PM
|
#1
|
LQ Newbie
Registered: Jan 2011
Posts: 25
Rep:
|
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
|
|
|
01-31-2011, 02:47 PM
|
#2
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
*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.
|
|
|
01-31-2011, 03:33 PM
|
#3
|
LQ Newbie
Registered: Jan 2011
Posts: 25
Original Poster
Rep:
|
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.
|
|
|
02-01-2011, 01:43 PM
|
#4
|
LQ Newbie
Registered: Jan 2011
Posts: 25
Original Poster
Rep:
|
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?
|
|
|
02-01-2011, 01:53 PM
|
#5
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
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.
|
|
|
02-01-2011, 03:29 PM
|
#6
|
LQ Newbie
Registered: Jan 2011
Posts: 25
Original Poster
Rep:
|
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 
|
|
|
02-01-2011, 03:32 PM
|
#7
|
LQ Newbie
Registered: Jan 2011
Posts: 25
Original Poster
Rep:
|
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)
|
|
|
02-01-2011, 03:32 PM
|
#8
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Quote:
Originally Posted by rlestage
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.
|
|
|
02-01-2011, 03:35 PM
|
#9
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Quote:
Originally Posted by rlestage
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.
|
|
|
02-02-2011, 11:59 AM
|
#10
|
LQ Newbie
Registered: Jan 2011
Posts: 25
Original Poster
Rep:
|
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.
|
|
|
02-02-2011, 07:04 PM
|
#11
|
Senior Member
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125
|
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, 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.
|
|
|
All times are GMT -5. The time now is 12:37 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|