Upgrading to MySQL5/PHP5 on FC2 Dedicated Server

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Upgrading to MySQL5/PHP5 on FC2 Dedicated Server

Post by RobertGonzalez »

I am about to set up a dedicated server. The host that I am using has Fedora Core 2 installed on their servers, along with all the applications that come with FC2. I am developing a network of sites that take advantage of some of the features of MySQL5 and PHP5 and I want to be able to upgrade MySQL and PHP on my dedicated server when I get it set up. Now to my question(s)...

I know next to nothing about Linux. I have ordered Linux in a Nutshell and have played around with Stanton Finley's Fedora Core 4 Installation Tutorial. But I am really not certain even how to shell into my dedicated server and I am really uncertain how to upgrade from the older versions of the software once I am in. Can some of the Linux guru's in this community help me out by pointing me to some newbie type tutorials or newbie instructions when it comes to things like this?

As always, all help is much appreciated.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Hi

If your on a Windows PC you can install Cygwin ( http://www.cygwin.com/ ) to get a shell.

From the shell you can type: ssh -l username ipordomain.com to get logged into a command prompt on the remote pc.

If the remote server is running x you can type ssh -Y -l username ipordomain.com and get a graphical environment from the server running on your windows box. That might help a little bit but most things need to be done from the command line anyway.

If you install yum on the remote server and configure it for FC2 you can log into the shell and type:

yum update php mysql and that will update them to the newest versions. Hope that helps a little bit.

Also, once you are logged into the remote server you can cd to a directory where you want to dowload packages and then use wget to download a file. I don't know the exact syntax but it's something like wget http://domainname.com/folder/file.tar.gz and that will save the file to the directory your in. You can then decompress it from the command line and install it. Running vi filename.txt will open a text editor but it's not user friendly at all.
Last edited by Benjamin on Tue Feb 21, 2006 1:03 pm, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

To get into your server from another linux machine you do:

Code: Select all

ssh username@yourdomain.tld
To do this from a windows machine you need to download puTTY. Google "putty download", it's always the first hit.

As for running upgrades on a fedora box. AFAIK, everything is done via Red Hat Package manager. So in the same way you'd uninstall or upgrade a program in windows by going to "Add/Remove Programs", you do it using RPM in FC.

I'd suggest reading up on the use of RPM but it's basically as easy as downloading the package:

Code: Select all

wget ftp://hostname/package-version-revision.rpm
... Then running it (upgrade or install)

Code: Select all

rpm -iv package-version-revision.rpm
Once you get used to it it's a breeze. FC has a huge community too so you'll have a ton of support ;)

EDIT | Doh too slow. The above post sounds more accurate than mine so use that :P Check out putty though... cygwin is a full environment, putty is just for SSH/telnet etc.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

I recently had the misfortune to be working on a dedicated server with Fedora installed (not sure which either 3 or 4). The app they were running required a minimum of MySQL 4.1, they took the decision to upgrade to MySQL 5. They upgraded via a binary package which amazingly enough seemed to go OK, but it did break Plesk (the SQL queries from plesk were using coloum names which are now reserved words in MySQL 5).

In their case it was not a major issue as they didn't use Plesk anyway, but just as a 'heads up', you might want to look at your box and see what else is dependant on MySQL and check it's compatability, prior to upgrading, I'm not so sure a downgrade/rollback across 2 major versions would have been as easy as the upgrade.

My personal take is that binary packages are fine as a quick way to get you up and running, but ideally I'd recommend looking into 'rolling your own' it's far more flexible than a binary package and makes compatability testing on your target system a lot easier. It also gives you a finer grain of control when it comes to performance tweaking too.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

redmonkey wrote:I recently had the misfortune to be working on a dedicated server with Fedora installed (not sure which either 3 or 4). The app they were running required a minimum of MySQL 4.1, they took the decision to upgrade to MySQL 5. They upgraded via a binary package which amazingly enough seemed to go OK, but it did break Plesk (the SQL queries from plesk were using coloum names which are now reserved words in MySQL 5).

In their case it was not a major issue as they didn't use Plesk anyway, but just as a 'heads up', you might want to look at your box and see what else is dependant on MySQL and check it's compatability, prior to upgrading, I'm not so sure a downgrade/rollback across 2 major versions would have been as easy as the upgrade.

My personal take is that binary packages are fine as a quick way to get you up and running, but ideally I'd recommend looking into 'rolling your own' it's far more flexible than a binary package and makes compatability testing on your target system a lot easier. It also gives you a finer grain of control when it comes to performance tweaking too.
One word. Gentoo.

It's built to compile from source *using the package manager* (portage). You can change the compile flags at install time so it's essentially like installing it yourself. IMHO Gentoo is "the" best server distro for that reason... customization.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

I think when it comes to server distros everybody has their personal favourite for their own personal reasons. My personal preference is Debian.
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

2 words, server management. Get someone who will manage your server security so you do no tneed to worry about that. You can get it for as cheap as $29.00 USD a month. You can use all of the extra time for developing whatever you might be hosting.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

OK, so I'm thinking that I don't like Plesk much. Mostly because, for some reason, it likes to use MySQL 3.23. Updating to MySQL 4.1.16 seems to be utterly difficult and updating to MySQL 5 is impossible (unless I don't mind dumping Plesk - which at the moment I am not minding so much).

I tried using yum to update mysql and php, but I get a message that both packages are already up to date (MySQL 3.23.58 and PHP 4.3.11). This is crap. I downloaded the MySQL 4.1.16 FC4 RPM from the Fedora Project download folder for FC4. But when I ran the rpm I got a warning saying that there was NOKEY or something to that effect. I am totally stumped (as a Linux newbie would be at this point). Can someone offer some suggestions?

I am about at the point where I am going to have the server wiped clean and start with a fresh install WITHOUT Plesk so I can get the PHP and MySQL versions I want.

Thanks for the help.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Don't know much about yum but perhaps you need to update the package list? But then I also remember that FC was at one time not offically supporting MySQL version above v3 so it my not be available via package installers like yum?

Anyway for MySQL I used the following script (which may or may not help you)....

Code: Select all

#!/bin/sh

#------------------------------------------------------------------------------
# filename     call it whatever you want :P
#
# description  installs/upgrades MySQL on RPM i386 based systems
#
# author       redmonkey
#
# status       alpha
#
# dependancy   none
#
# license      this program is free software, you can redistribute it and/or
#              modify it
#
# copyright    2005 redmonkey, all rights reserved
#
# history
# 03/09/05     v0.1 - initial version
#
# tested
# 03/09/05     Fedora Core 3, kernel v2.6.8
#
#
# notice       this program is distributed in the hope that it will be useful
#              but WITHOUT ANY WARRANTY; without even the implied warranty of
#              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#------------------------------------------------------------------------------

#----------------------------START OF USER CONFIG-----------------------------#

#------------------------------------------------------------------------------
#
# define your root password for your current MySQL installation
#
#------------------------------------------------------------------------------
ROOTPASSWD=password

#------------------------------------------------------------------------------
#
# define which version of MySQL you want to install (major and minor)
#
#------------------------------------------------------------------------------
VERSION=4.1

#------------------------------------------------------------------------------
#
# some RPMs are called $VERSION-0 and sometimes $VERSION-1 you may need to 
# change this (MINOR=0 worked the last time I used this)
#
#------------------------------------------------------------------------------
MINOR=0

#-----------------------------END OF USER CONFIG------------------------------#


#------------------------------------------------------------------------------
# check that $VERSION has been defined, resort to v4.1 if not
#------------------------------------------------------------------------------
if [ -z ${VERSION} ]; then
    echo "VERSION has not been set, will arrempt to install MySQL v4.1"
    VERSION=4.1
fi

#------------------------------------------------------------------------------
# get the latest full version string (i.e. 4.1.18)
#------------------------------------------------------------------------------
if [ ${VERSION} = "4.1" ]; then
  WEBPAGE="http://dev.mysql.com/downloads/mysql/4.1.html"
elif [ ${VERSION} = "5.0" ]; then
  WEBPAGE="http://dev.mysql.com/downloads/mysql/5.0.html"
fi

VERSION=$(wget -O - ${WEBPAGE} 2>&1 | grep "Pick a mirr" | grep mysql-stand | \
          head -n 1 | sed 's/.*mysql-standard-//g' | sed 's/-.*//g')

if [ ! -z ${VERSION} ]; then
  echo "Installing $VERSION"
else
  echo "Failed to determine specific MySQL version required"
  exit 1
fi
            

#------------------------------------------------------------------------------
# work out which version directory on the server we should be downloading from
#------------------------------------------------------------------------------
VERDIR=4.1

if echo ${VERSION} | grep -q 5.0 ; then
  VERDIR=5.0
fi

#------------------------------------------------------------------------------
# grab the RPMs, skip those which we already have
#------------------------------------------------------------------------------
for RPM in "MySQL-client" "MySQL-devel" "MySQL-shared-compat" "MySQL-server"
do
FILE=$RPM-$VERSION-$MINOR.i386.rpm
if [ -e $FILE ] ; then
  echo $FILE already downloaded, skipping it
else
  URL="http://mysql.mirrors.pair.com/Downloads/MySQL-$VERDIR/$FILE"
  echo Fetching $URL
  wget --quiet $URL
  if [ $? -ne 0 ]; then
    echo "$URL could not be downloaded." >&2
    exit 1
  fi
fi
done

#------------------------------------------------------------------------------
# stop the current MySQL server instance
#------------------------------------------------------------------------------
if [ -e /etc/rc.d/init.d/mysql ]; then
  `/etc/rc.d/init.d/mysql stop`
elif [ -e /etc/rc.d/init.d/mysqld ]; then
  `/etc/rc.d/init.d/mysqld stop`
fi

#------------------------------------------------------------------------------
# actually install the RPMs
#------------------------------------------------------------------------------
rpm -Uvfh "MySQL-*$VERSION*.rpm"
if [ $? -ne 0 ]; then
  echo "Failed to install MySQL rpms" >&2
  exit 1
fi

#------------------------------------------------------------------------------
# config MySQL to run at boot time
#------------------------------------------------------------------------------
chkconfig --level 35 mysql on

#------------------------------------------------------------------------------
# RPM installs seem to have a habbit of removing the current mysql user
#------------------------------------------------------------------------------
if ! grep -q mysql /etc/passwd ; then
  `useradd -s /sbin/nologin mysql`
  `chown -R mysql:mysql /var/lib/mysql`
fi

#------------------------------------------------------------------------------
# config MySQL server to accept old password style authentication
# (it's a PHP thing)
#------------------------------------------------------------------------------
if ! grep -qai old-passwords /etc/my.cnf ; then
  replace "[mysqld]" "[mysqld]
  old-passwords" --  /etc/my.cnf
fi

#------------------------------------------------------------------------------
# crank up MySQL server and wait for it to start
#------------------------------------------------------------------------------
`/etc/rc.d/init.d/mysql restart`
`sleep 10`

#------------------------------------------------------------------------------
# restore the root users password if it's been set
#------------------------------------------------------------------------------
if [ ! -z "$rootpasswd" ] ; then
  `/usr/bin/mysqladmin -u root old-password "${ROOTPASSWD}"`
  `/usr/bin/mysqladmin -u root -h `hostname` old-password "${ROOTPASSWD}"`
else
  echo "No root user password set.  It's recommended you set the root password"
fi

exit 0
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

If you decide to wipe the server and start over you might want to try this.

Install Fedora Core (any version) but turn off the Apache, Mysql and PHP options in the install so they are not installed.

The download and install Xampp for Linux. It will take you about 15 minutes to install and set all of the security provisions.

You will have all of these items automatically installed.

Apache 2.2.0, MySQL 5.0.18, PHP 5.1.1 & 4.4.1 & PEAR + SQLite 2.8.9/2.8.14 + multibyte (mbstring) support, Perl 5.8.7, ProFTPD 1.2.10, phpMyAdmin 2.7.0-pl2, OpenSSL 0.9.8a, GD 2.0.1, Freetype2 2.1.7, libjpeg 6b, libpng 1.2.7, gdbm 1.8.0, zlib 1.2.3, expat 1.2, Sablotron 1.0, libxml 2.4.26, Ming 0.2a, Webalizer 2.01, pdf class 009e, ncurses 5.8, mod_perl 2.0.1, FreeTDS 0.63, gettext 0.11.5, IMAP C-Client 2004e, OpenLDAP (client) 2.3.11, mcrypt 2.5.7, mhash 0.8.18, eAccelerator 0.9.3, cURL 7.13.1, libxslt 1.1.8, phpSQLiteAdmin 0.2 and libapreq 2.06-dev

You can then easily select between PHP 5 or PHP 4 since it contains both versions with SSL.

Now you will hear some people say don't do it because you need to learn how to install it yourself. Pish...

We have a number of commerical servers we have setup using this method. We can get a complete from scratch install of Fedora Core 4 and Xampp with all of the necessary security settings installed (even changing the ports for SFTP, SSH, ect to something different) in about 30 minutes.

The other great thing about it is upgrading is fairly easy if you want to upgrade Xampp when they come out with new versions of the installed packages.

It just makes setting up a server so much easier.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

WOW, thanks for the cool information and details. So here is what I got. Maybe you can walk me through it (if you don't mind holding my hand a bit).

I now have a fresh FC2 server with all of the standard FC2 installations. It is working a lot better than the Plesk set up, but it is still the same set up application wise. One of the first things I did was a yum update and the response was that all packages were up to date and there were no actions to take. I think there is something in the configuration of the server or the OS that is telling it that everything is up to date.

I didn't really have the option of a clean sweep so I took the standard installation. Now I want to update. Using Xampp, can it be done with all of the services running? Apache is running, MySQL is running, everything is running. Can I install Xampp without killing my box? Again, I am very wet behind the ears when it comes to anything Linux.

Thank you all for your help. You are all wizards in my book.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

redmonkey wrote:Don't know much about yum but perhaps you need to update the package list? But then I also remember that FC was at one time not offically supporting MySQL version above v3 so it my not be available via package installers like yum?

Anyway for MySQL I used the following script (which may or may not help you)....
So, let's say I was a Linux newbie. How would I go about running this script? Another thing... if I was going to pay a Linux geek to freakin' fix this for me (and then tell me what was done after the fact) how much should I budget? I need to get this server up to snuff sooner than later and am seriously considering paying someone to do it.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

To run the script.. save it out to a file (note, you need to save it with UNIX line endings), copy/upload it to your server. There are also a couple of vaiables that you may wish to change (there are some notes in the script itself between the -- users config --- section)

From the command line (you'll probably need to logged in as the root user for the script to run completely), you first have to set the execute permission so either...

Code: Select all

chmod +x filename
or..

Code: Select all

chmod 0500 filename
It's probably easier to do the former should you need to change/edit the script at all. Then it's a simple case of running it...

Code: Select all

./filename
With regard paying someone to sort it out and document exactly what they have done, really depends on the servers current state and exactly what sort of setup you are after?

Different people have different takes, personally I don't like binary packages for production servers and favour rolling my own I feel this approach gives me that little extra bit of flexability when it comes to upgrading plus it means I can also tailor the install to my specific requirements.

A binary package certainly offers an easy method to get you up and running and in little time too, I'd expect someone who knows what they are doing to be able to install the required packages for a basic webserver in around 1-2 hours that includes, the various config files, tweaking and testing.

To roll your own.. normally takes me a day (a long day lol) although a lot of time is spent hanging around waiting for things to compile and documenting exactly the steps taken, that includes compiling and installing, Apache (with SSL and other required modules), PHP (with various additional modules/extensions as per required), MySQL, PostgreSQL, a pop3 deamon (normally popa3d with SSL support), a FTP server (normally ProFTPd with SSL support), CVS or SVN (if required), firewall setup (using iptables), a MTA (if required, I normally just use which ever one happens to be installed) and all the required libraries and headers that go along with these packages, basically a base webserver type package.

As for price, I've seen prices vary wildly, if you just need someone to install the stuff via binary packages I would expect you could get that done for about $200, if you want full on step by step documentation and everything hand rolled taking your requirements into consideration, I would expect somewhere along the lines of $1500.

I don't actually pay attention to going rates etc.. so the figures above are just a complete guess, so I could be way off base.

If your server is going to be used as a 'true' production server, I would definately consider getting someone with experience to do the initial install/prep/setup.
Post Reply