|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Jan 08, 2009 3:05 am
Moving to a new server soon |
This week I am working with WolfPaw to move our site to a new server. Our current server is very old and is costing more money to maintain. WolfPaw has a better server option that is less expensive and more powerful, so we have agreed to switch over soon.
In order to better manage the server myself, I am actively working on the server configuration myself. In the past I haven't been very comfortable with the server. It's not a "standard" distribution setup, and I never know where to find anything. Building new versions of software like PHP is always a pain. There wasn't any sort of rpm or yum system for downloading prebuilt software packages.
The new server is a CentOS 5.2 system, so there is a lot of help and support for it. I'm also looking at a free "control panel" called Virtualmin (based on Webmin) for setting up virtual servers (like the SlightlyMorbid.com server) and for allowing web-based admin when I'm not at my main computer.
I spent a long, frustrating day on all of this today. Apparently CentOS 5.2 comes with PHP5 instead of PHP4. This PHP4 stuff is becoming a curse! I am having a heck of a time just getting PHP4 installed and working on the server. And then I need to figure out how to make PHP4 and PHP5 co-exist on the same server somehow so that I can convert this site to PHP5 later this month.
I just can't believe how hard this all is. You'd think Apache and PHP were common enough that it would be designed to handle both PHP4 and PHP5 at the same time. But it seems to be extremely difficult. When I look for help, the commands are for some other variant of linux and don't work on my CentOS system.
There is a "Pro" version of Virtualmin that installs both PHP4 and PHP5 and lets you easily switch between them, but I can't really afford to pay for that. It's not like I'm running a virtual hosting reseller program here...I just want to get it working for a couple of virtual sites so I can create the new PHP5 without impacting the current PHP4 site.
I've done a ton of Google searching and have found tons of articles that make it seem easy to just install MOD_PHP for one version, and use the CGI for the other version. But so far I haven't actually found any instructions that work on my specific server. On CentOS 5.2, PHP5 is loaded via the Apache mod_php5. So it is "built in". I have a libphp4.so library, but I don't have any php4-cgi files. So I'm still missing something.
And right now, when I type "php4 -v" I get errors about:
Quote: |
Unable to load dynamic library '/usr/lib64/php4/mysqli.so' |
so there is something missing between PHP4 and Mysql support too.
So, lots and lots of hours spent today with very little results. But I'll let you know as I make more progress and I'll definitely give a warning before we officially switch over to the new server hardware. |
|
|
|
calesta Apprentice
Joined: 07 Dec 2008 Posts: 102 Location: New Hampshire, USA
|
Posted: Thu Jan 08, 2009 5:05 am |
I ran across this thread while poking around for information on how to do this. Haven't tried it myself, and its for an older version of CentOS, but figured I'd post it just in case you hadn't seen it and it helps get you going faster.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Jan 08, 2009 6:06 am |
Yep, that was one of the pages that I found too. The problem is that it is for CentOS 4.4 rather than CentOS 5.2. In v5.x they started distributing PHP5 by default instead of PHP4, so building PHP4 gets a bit trickier. Also, using the Apache "Action" command causes it to launch the PHP binary for each page, which really kills the server performance. So I'm still hoping to do it using the libphp4.so library rather than launching php4 directly.
I'll still whine that I'm surprised neither PHP4/5 or Apache is written in such a way to allow both to be installed into Apache at once. After all, you can have python, perl, ruby, etc all installed into Apache at the same time, so why not PHP4 and PHP5. Apparently other servers such as lighthttpd can handle both at the same time, so why not Apache? I'd be interested in learning what the actual limitation of this really is.
It's all just some evil plot to remove PHP4 from the world for some reason. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Jan 08, 2009 10:16 pm |
(NOTE: The following is all for CentOS 5.2)
Well, I made some progress today. I found that the Virtualmin people had set up a "yum" repository for CentOS 5.2 that has the php4 binaries. I got this set up automatically in my yum search tree when I installed Virtualmin. Looks like the repository is at software.virtualmin.com for people who need that.
In any case, I installed PHP4 using "yum install php4", which also installed php4-pear. Doing "php4 -v" properly showed the PHP4 version. Then I did "yum install php4-mysql" and this time it worked. The mysql.so file was properly placed into the /etc/php4/php.d directory. So far so good.
Now, in the Apache configuration, what I didn't realize is that not all of the configuration is stored in /etc/httpd/conf/httpd.conf. There are many other *.conf files loaded from /etc/httpd/conf.d. In that directory was the php.conf for PHP5 and the php4.conf for PHP4.
If you do a "ls /usr/bin/php*" you will see "php" (PHP5), "php4" (PHP4-FCGI) and "php-cgi" (PHP-FCGI). So, don't be confused like I was thinking that I didn't have the PHP4 CGI binary. The php4 file *is* the FCGI binary and not the command line php tool. This was confusing until I read the output of "php4 -v" more carefully.
OK, back to Apache. Now you have to decide which version of PHP will run via the Apache module, and which via FastCGI (FCGI). In my case I plan to run more PHP4 right now, so I want it to be the fastest. Once all of my sites are converted to PHP5 then I'll come back and make PHP5 run as an Apache module.
Since I want PHP4 to run as an Apache module, I edited the "php4.conf" file in the /etc/httpd/conf/conf.d folder. I uncommented the "LoadModule php4_module modules/libphp4.so" line, and uncommented the "AddType application/x-httpd-php .php .php4" line (and added the .php so that PHP4 is used by default).
Next, I edited the "php.conf" for PHP5. To convert this to use FCGI instead of an Apache module I commented out the "LoadModule...libphp5.so" line. And I changed the "AddHandler php5-script .php" to "AddHandler php5-script .php5" so that PHP5 is only executed by files with *.php5 extensions. Then I added the line:
"Action php5-script /cgi-bin/php5" to the file. This tells Apache to call the php5 CGI binary when running *.php5 files.
Now restart Apache (/sbin/service httpd restart). The next step is to create the CGI link. This is the step that I was missing (and is missing from a lot of tutorials). Go to the cgi-bin directory for the virtual host that you want to use PHP5 CGI. Like /home/mysite/cgi-bin. Now create a link for the PHP5 CGI using "ln /usr/bin/php-cgi php5". This points the php5 that we called from Apache config to the actual PHP5 FCGI binary (php-cgi).
The final step that took me a while to figure out is that you need to set the permissions of this file properly. You need to do a "chown username php5" and "chgrp groupname php5" in the cgi-bin directory to match the username and groupname of the directory. Just do a "ls -al" to see the username and group of the cgi-bin directory and make the php5 have the same values. Otherwise you will just get a blank page for *.php5 files and you'll see the error message in your /etc/httpd/logs/suexec.log file.
In general, it's good to look at the Apache log files in /etc/httpd/logs to see what it says when Apache restarts or when you try to request a PHP page. That is what helped me.
With all of this, you can then create some files: phpinfo.php, phpinfo.php4, and phpinfo.php5. In each file, just put:
<?php
phpinfo();
?>
And then try to load each one from your browser. You should see that the *.php and *.php4 files will show PHP v4.4.8, and the *.php5 will show PHP v5.1.6
As I said, in this example I am making PHP4 the default, and PHP5 the exception. For any site that you want to run PHP5, you need to add the link to the PHP5 CGI in the cgi-bin directory of that virtual host. You can also add a .htaccess file to map *.PHP files to *.PHP5 for those sites where you want PHP5 by default.
So this is finally working for me. Seems straight-forward now that I review it all. The tricks were noticing all of the extra *conf files in the conf.d directory, and then setting the proper ownership of the CGI link. Hope this helps someone else.
Edited: Btw, to give credit where it is due, the tutorial that helped me the most on this is at: http://www.deanspot.org/~alex/php5fcgi/index.html It's a slide-show for the web browser (you might need to adjust your text size smaller to see everything on the pages). Clicking the page goes to the next page. Not sure how to go back to a previous page. Anyway, this had pretty clear instructions that really helped me. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Jan 13, 2009 10:15 pm |
Looks like we are ready for the switch-over tomorrow (Wed). Today I moved most of the site and tested it. I had lots to fix, so hopefully I found everything.
I got Zend Optimizer installed for both PHP4 and PHP5. That was easy. Transferred our HelpDesk system and once I realized it was asking me for an email address and not a user name, it went fine.
The main problem was that the version of xCart that I'm using for the Zuggsoft store doesn't support MySQL v5, which is what the new server is running. Looks like mainly a problem with the syntax they used for JOIN statements. I found a patch that seems to make it work in MySQL 5 without needing to do a full upgrade of xCart, which I really wanted to avoid since I'm not going to be using it much longer anyway. But that took a while to find.
I also found some problems related to differences in the PHP.INI file that I was able to fix. I also had to increase the memory limit for PHP scripts for some reason. Maybe it's because the new server is 64bit and the old one is 32bit? Moving the databases only took about 15 minutes, so that's about how much downtime I expect tomorrow when I turn off the current httpd server and then transfer the latest database to the new server. Then we'll switch IP addresses and bring up the new server.
I wasn't able to test everything because it's impossible to make the new server work *exactly* like the current server as long as the current server DNS entries are active. I edited my local Hosts file to trick it into going to the new server for most of my testing, but that doesn't work for everything. My guess is that I'll be spending the day tomorrow cleaning up a bunch of loose ends. But I'll post to the forums when I'm ready for people to test the new server.
Finally, we sure do have a lot of "junk" on this server. While I was watching the file transfer I saw all sorts of old files and directories that we don't use anymore (I think). It's going to be nice putting together a "clean" site later this month. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|