# Ports Q: How best to upgrade Apache and MySQL?



## Samwise (Nov 4, 2009)

Hi,

I'm fairly new to FreeBSD but have experience with Linux and Solaris.

I'm struggling to get to grips with upgrading software in FreeBSD.  I have inherited a headless FreeBSD server that is listed as 7.0-RELEASE-p12 in the output of uname -a.  I think it's running a custom kernel.

It uses cvsup to update the Ports Collection, as I understand it.

I've updated to the latest versions of the (L)AMP stack, which results in these versions:

Apache HTTP Server 2.0.63
MySQL 5.0.87 server
PHP 5.2.11

Now, I'd quite like to upgrade the HTTP Server to 2.2 and MySQL to 5.1.  When PHP 5.3 reaches ports I'd also like to upgrade to that, which I assume will be a similar scenario.

So, what is the preferred mechanism for upgrading these two components up minor versions, bearing in the mind that there is already one website running on the server which is using a database?  Backing up etc. shouldn't be a problem.

Any guidance would be greatly appreciated ...

Thanks,

Sam.


----------



## SirDice (Nov 4, 2009)

For apache it's relatively simple, just remove the old one with pkg_delete and install the new one. Verify that the configs are correct. Do note that for 2.0 these are in /usr/local/etc/apache20/ and for 2.2 they're in /usr/local/etc/apache22/. So you may need to move some stuff around.

Pretty much the same deal with MySQL only the configs for both versions are in /usr/local/etc/. You may need to run a script to upgrade the databases themselves. The message will be displayed after you've installed mysql.


----------



## Samwise (Nov 4, 2009)

That sounds quite straightforward, thanks for the clarification, SirDice.

One last question - is there any preferred order?  How do I ensure that Apache 2.2 gets the php module built etc.  I assume there's an interdependency of sorts between these three.

Do I need to put entries in /etc/make.conf or /etc/rc.conf?  I've read about those in various guides on the net, but not quite sure which to follow.

Thanks,

Sam.


----------



## SirDice (Nov 4, 2009)

Samwise said:
			
		

> One last question - is there any preferred order?  How do I ensure that Apache 2.2 gets the php module built etc.  I assume there's an interdependency of sorts between these three.


The apache port doesn't build the php module. That's done by the php port. You may have to rebuild that one after you've updated apache.



> Do I need to put entries in /etc/make.conf or /etc/rc.conf?


I wouldn't put anything in make.conf, certainly no compiler optimizations. If anything doesn't work first thing everybody will tell you is to remove those. The speed increase will be minimal at best anyway. Rc.conf might need a little adjustment apache20_enable -> apache22_enable.

I'd start with mysql. That's probably the easiest with the least amount of impact. Once everything works move to apache and last php.


----------



## Samwise (Nov 4, 2009)

OK, so I'll upgrade MySQL first, then Apache and finally rebuild PHP.  Hopefully, that should cater for everything ...

As for /etc/make.conf, I wasn't thinking about optimisations etc.  I've seen in some guides that you need to add variables like:

```
APACHE_VERSION=22
WITH_MYSQL_VER=51
```
In order for things to build against the right versions.  Is that required, or is it outdated information?

Sam.


----------



## Samwise (Nov 4, 2009)

To add - the reason I ask the question is that those variables aren't already in /etc/make.conf and so would need adding, otherwise I'd've just updated them.

Sam.


----------



## SirDice (Nov 4, 2009)

I've never used them. Unless you build php5-mysql i.e. from scratch the port will just use the mysql-server and apache version that's installed.


----------



## Samwise (Nov 4, 2009)

Hmm. ... just looked at php5-mysql, which is described as "The mysql shared extension for php".

So, this is used to ensure that PHP apps can connect to the mysql database.  It sounds like I would need to reinstall this too?  Though looking at the entry in the ports search, it appears to have MySQL client 5.0 listed as a dependency, when I want to move up to 5.1?

Sorry for all the questions, I just want to make sure the upgrade goes smoothly!

Sam.


----------



## SirDice (Nov 4, 2009)

I have mysql-server-5.1 installed and my php5-mysql built with 5.1 support. The php5-mysql port will install, by default, mysql50-client if there is no mysql-client installed.


----------



## Samwise (Nov 4, 2009)

OK, so:

- pkg_delete MySQL Server 5.0
- pkg_delete MySQL Client 5.0
- "make install" MySQL Server 5.1
- run update script (if told to)
- "make install" MySQL Client 5.1

- pkg_delete Apache 2.0
- "make install" Apache 2.2
- update Apache 2.2 config (in new location) as required

- "make install" php5 to rebuild it

- "make install" php5-mysql to rebuild it

Sound like a sensible plan?

Peter.


----------



## gilinko (Nov 4, 2009)

First of all, dump your entire database structure to file as backup so nothing is lost by accident. And when you compile/install the mysql-server port you will get the client libraries to as these are required by the server. So no need for that step.


----------



## Samwise (Nov 4, 2009)

Yep, I intend to make backups of the database and webserver files, so no worries there.  OK, well, as I now have what seems like a sensible plan that noone has ridiculed, I'll give it a go tonight!

Thanks.


----------



## Samwise (Nov 5, 2009)

Touch wood, the upgrade seems to have gone off OK ...

Thanks, all.

Sam.


----------



## SirDice (Nov 5, 2009)

You're done upgrading? That was quick :beer


----------



## Samwise (Nov 5, 2009)

Yep, all thanks to the good planning (and the assistance here!).  

Also, just realised that I missed marking the topic as [Solved].  Sorry 'bout that - I was using the Quick Reply box and am not that familiar with vBulletin yet.

Sam.


----------

