Fedora 4 + Apache2 + Php5 + APC + MySQL + Webmin
The shell script below will build a Fedora 4 based server with little effort. I have used this on several servers with no problems. Always use the latest versions of software and update the script with the proper version numbers. By compiling Apache and PHP we noticed a 30% increase in benchmark speed for our Xeon servers over the standard Fedora binaries which you can verify using Apache AB.
Files to download to /usr/local/src:
MySQL
www.mysql.com (binary tar.gz)
Apache
www.apache.org (source tar.gz)
APC pecl.php.net (source tar.gz)
Php
www.php.net (source tar.gz)
Webmin
www.webmin.com (noarch.rpm)
Net_SSLeay cpan.org (source tar.gz)
#!/bin/sh
# Script to build a Fedora based Linux server
# 1. Install Fedora Core 4 with only Development tools installed (use Custom Install)
# 2. Run this script to complete server build, remember to put the latest tar balls/rpms in /usr/local/src first
#******** Software to install, edit to latest versions ************************************
mysql=mysql-max-5.0.16-linux-i686-glibc23
apache=httpd-2.0.55
apc=APC-3.0.8
php=php-5.1.1
webmin=webmin-1.250-1.noarch.rpm
Net_SSLeay=Net_SSLeay.pm-1.25
##############################################################################
cd /usr/local/src
tar zxvf $apache.tar.gz
tar zxvf $apc.tgz
tar zxvf $php.tar.gz
tar zxvf $Net_SSLeay.tar.gz
tar zxvf $mysql.tar.gz
#**** Use Yum to update the server first
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* #fixes GPG key errors for ghostscript fonts
yum install ImageMagick
yum update openssh*
yum update zlib-devel*
# ****************** Install MySQL (binary distro) ******************
groupadd mysql
useradd -g mysql mysql
cd /usr/local
tar -zxvf /usr/local/src/$mysql.tar.gz
ln -s $mysql mysql
cd mysql
scripts/mysql_install_db --user=mysql
chown -R root:mysql /usr/local/mysql
chown -R mysql /usr/local/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 0755 /etc/rc.d/init.d/mysqld
chkconfig --levels 2345 --add mysqld # for auto startup
#****************** Apache *********************************************
cd /usr/local/src/$apache
./configure \
--prefix=/usr/local/apache2 \
--enable-so \
--enable-ssl
make
make install
mkdir /usr/local/apache2/conf/ssl.key
mkdir /usr/local/apache2/conf/ssl.crt
cd /usr/local/apache2/conf/ssl.key
openssl genrsa -des3 -rand some_big_file_1:some_big_file_2 -out localhost.key 1024
openssl rsa -in localhost.key -out server.key
openssl req -new -key localhost.key -out localhost.key.csr
openssl x509 -req -days 365 -in localhost.key.csr -signkey localhost.key -out /usr/local/apache2/conf/ssl.crt/server.crt
#*** Create a Simple Apache Startup script in /etc/init.d
echo "#!/bin/sh
# description: apache2
# chkconfig: 2345 99 00
case \"\$1\" in
'start')
/usr/local/apache2/bin/apachectl startssl
touch /var/lock/subsys/httpd
;;
'stop')
/usr/local/apache2/bin/apachectl stop
rm -f /var/lock/subsys/httpd
;;
*)
echo \"Usage: \$0 { start | stop }\"
;;
esac
exit 0" > /etc/init.d/httpd
chkconfig --levels 2345 --add httpd # for auto startup
chmod 0775 /etc/init.d/httpd
# ********************* PHP ***********************************************
cd /usr/local/src/$php
if [ -f config.cache ] ; then
rm config.cache
make clean
fi
./configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql-sock=/tmp/mysql.sock \
--with-mysql=/usr/local/mysql \
--with-zlib \
--with-zlib-dir \
--with-curl \
--enable-track-vars \
--with-config-file-path=/usr/local/apache2/conf \
--enable-trans-id \
--enable-mbstring \
--enable-sockets \
--with-openssl
make
make install
cp /usr/local/src/$php/php.ini-dist /usr/local/apache2/conf/php.ini
echo "AddType application/x-httpd-php .php" >> /usr/local/apache2/conf/httpd.conf
echo "<?phpinfo()?>" > /usr/local/apache2/htdocs/phpinfo.php
#*********** APC (PHP opcode cache) *************************************
cd /usr/local/src/$apc
phpize
./configure --enable-apc \
--with-apxs=/usr/local/apache2/bin/apxs \
--with-php-config=/usr/local/bin/php-config
make
make install
EXT=$(find /usr/local/apache2/conf/ -name 'php.ini' -exec grep -li 'extension=apc.so' {} \
if [ ! $EXT ] ; then
echo "extension=apc.so" >> /usr/local/apache2/conf/php.ini
fi
EXT=$(find /usr/local/apache2/conf/ -name 'php.ini' -exec grep -li 'extension_dir = "/usr/local/lib/php/extensions/"' {} \
if [ ! $EXT ] ; then
echo "extension_dir = \"/usr/local/lib/php/extensions/"\" >> /usr/local/apache2/conf/php.ini
fi
if [ ! -f /usr/local/lib/php/extensions/apc.so ] ; then
APC_SO=$( find /usr/local/lib/php/extensions/ -name apc.so )
ln -s $APC_SO /usr/local/lib/php/extensions/apc.so
fi
#********** Net_SSLeay SSL for Webmin *********************
#********* export command fixes bug in perl makefile ******
cd /usr/local/src/$Net_SSLeay
export LANG=en_US
perl Makefile.PL
make install
#*************** Webmin ***********************************
cd /usr/local/src/
rpm -U $webmin
echo "************************************"
echo "************************************"
echo "Script has finished"
echo "Stop iptables \"/etc/init.d/iptables stop\""
echo "Open port 10000 & 443 in Webmin->Networking->Linux Firewall"
echo "Go into Webmin->System->Bootup and disable all non esential services"
echo "You should reboot server now, then check PHP with
http://localhost/phpinfo.php"
เผื่อจะได้ใช้งานในส่วนของ mayoo's web service ด้วยนะครับ มันน่าสนใจดีครับ...