I will show you how to upgrade your apache to the latest version without downtime, and also some tips to get out the best performance from your apache.
First, rename your apache folder to something like "apachebak". This allows you to compile the new apache in the same directory as the old apache, and you can have a backup of your old apache, if something goes wrong.
#change to apache parent directory cd /home/web/ mv apache apachebak
Next thing is to get the sources. If you don't have them
#change to your sources directory cd /home/sources/ wget http://www.apache.org/dist/httpd/httpd-2.2.6.tar.gz
Now extract the sources
gunzip < httpd-2.2.6.tar.gz | tar xvf -
Before I start compiling, I use some gcc flags to speed up apache. You can read how to compile with optimization, to optimize the code for your machine
#this enables compilation with my both cores #i have a dual core machine and i must use -j3, #if you have a quad core machine for example you must use -j5 export MAKEOPTS=-j3 #these are CFLAGS for my machine, core 2 duo export CFLAGS="-O3 -march=nocona -freorder-blocks / -fno-reorder-functions -mmmx -mno-mmx -msse -msse2 / -mno-sse2 -msse3 -mno-sse3 -mssse3 -mno-ssse3 -mfpmath=sse" export CXXFLAGS="-O3 -march=nocona -freorder-blocks / -fno-reorder-functions -mmmx -mno-mmx -msse -msse2 / -mno-sse2 -msse3 -mno-sse3 -mssse3 -mno-ssse3 -mfpmath=sse"
If you want to compile your code on 64 bit linux, apache has a bug that fails compilation. Here is how to fix the apache bug
And now we can start the compilation
./configure --prefix=/home/web/apache --enable-so --enable-rewrite --disable-cgi --disable-cgid --disable-autoindex --with-mpm=worker --enable-nonportable-atomics=yes --enable-lib64 --libdir=/usr/lib64 && make && sudo make install
Note: If you have a 32 bit machine then remove "--enable-lib64 --libdir=/usr/lib64" from the configure line
Now, the compilation is complete. You can edit your httpd.conf install php module or other modules and you can stop the old apache and start the new apache
#this will kill the old apache process and will start the new apache process kill `cat /home/web/bakapache/logs/httpd.pid` /home/web/apache/bin/apachectl -k start
Note:If you upgraded from apache 2.2.* you can just copy "conf" and "modules" from your old apache and they will run without problems, because modules are built with Apache 2.0 handler, and they are compatible
#this will copy configuration files and modules rm -R /home/web/apache/conf cp -R /home/web/bakapache/conf /home/web/apache/conf #copy modules rm -R /home/web/apache/modules cp -R /home/web/bakapache/modules /home/web/apache/modules
Share this with the world
Related
Comments
Thanks for putting this page together...saved me some time in compiling 64-bit Apache 2.2.x. Wanted to pass on one note of interest:
Posted on 2008-07-14 11:18:58Setting --libdir=/usr/lib64 and compiling as a non-root user may cause problems during make install, as the install portion of the build will want to place some apr-related libraries in the directory that you set as libdir. So, if you are running an OS that already has files present that are related to apr via an already installed package, the make install will fail.
In my case, I set --libdir=$APACHE_HOME/lib64 and the make install completed without a hitch. The apr-related libraries are placed in $APACHE_HOME/lib64 and the make install process also updates the envvars file to include a LD_LIBRARY_PATH declaration which includes the --libdir specified during configure, so the proper apr-related libraries will be used during runtime.
Thanks again!
don't these contradict each other? enable and disable?
Posted on 2008-09-23 15:43:49-mmmx -mno-mmx
-msse2 -mno-sse2
-msse3 -mno-sse3
-mssse3 -mno-ssse3
Make yourself heard