LAMP

From Leo's Notes
Last edited on 21 August 2017, at 20:49.

This is an old script that I used to set up a LAMP server.

cd
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm
rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm

yum -y install make autoconf g++ gcc-c++ libtermcap-devel libgcc-c++ libtool gcc libpng-devel libjpeg-devel libxml1-devel libxml2-devel curl curl-devel libmcrypt libmcrypt-devel libtool-ltdl-devel libxml2.x86_64 libxml2-devel.x86_64 curl-devel.x86_64

# mysql
yum -y install cmake

# sphinx
yum -y install sudo

#apache
yum -y install openssl openssl-devel

# Get IPtable rules
wget http://host.steamr.com/supportfiles/iptables.sh

cd /root
mkdir src

cd /root/src
wget http://host.steamr.com/supportfiles/httpd-2.2.21.tar.gz
wget http://host.steamr.com/supportfiles/mysql-5.1.59.tar.gz
wget http://host.steamr.com/supportfiles/php-5.3.8.tar.gz
wget http://host.steamr.com/supportfiles/sphinx-2.0.1-beta.tar.gz
for f in `ls *.tar.gz` ; do tar -xzf $f ; done

#
# Setting up apache
#
cd /root/src/http*/
./configure --prefix=/opt/apache --enable-so --enable-rewrite --enable-ssl --enable-setenvif
make -j 4 && make install && wget -O /etc/init.d/httpd http://host.steamr.com/supportfiles/httpd.sh && chmod 755 /etc/init.d/httpd && wall Apache Installed!

wget -O /opt/apache/conf/httpd.conf http://host.steamr.com/supportfiles/httpd.conf
ln -s /etc/init.d/httpd /etc/rc3.d/S55httpd

# Note: The above preconfig .conf will load php which is not compiled yet. 
# Do not start apache.
#/etc/init.d/httpd start

#
# Setting up MySQL 5.1 with sphinx
#
cd /root/src/mysql*/

cp -R ../sphinx-*/mysqlse/ storage/sphinx
sh BUILD/autorun.sh
./configure --prefix=/opt/mysql --with-plugins=sphinx --with-unix-socket-path=/opt/mysql/mysql.sock --without-man --enable-shared  --without-debug --enable-assembler --with-ssl CFLAGS=-O3 'CXXFLAGS=-O3 -fno-exceptions -felide-constructors -fno-rtti' CXX=gcc 
make -j 4
make install && wall MySQL Installed

/bin/cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
ln -s /etc/init.d/mysql /etc/rc3.d/S40mysql
/bin/cp support-files/my-medium.cnf /etc/my.cnf
/usr/sbin/useradd -r mysql
cd /opt/mysql
chown -R mysql .
chgrp -R mysql .

# When using mysql 5.1:
/opt/mysql/bin/mysql_install_db --user=mysql

# When using mysql 5.5, use:
#/opt/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql

chown -R mysql /opt/mysql
/opt/mysql/bin/mysqld_safe --user=mysql &

#
# Set the lib paths of mysql so the libmysqlclient.so or w/e can be found
#
echo "/opt/mysql/lib/mysql" > /etc/ld.so.conf.d/mysql.conf
/sbin/ldconfig

# apply custom settings
wget -O /etc/my.cnf http://host.steamr.com/supportfiles/my.cnf
killall mysql
killall mysqld
/etc/init.d/mysql restart


#
# sphinx
#
cd /root/src/sphinx*
./configure --prefix=/opt/sphinx --with-mysql
make -j 4
make install

# post install stuff
/bin/cp /opt/sphinx/etc/sphinx.conf.dist /opt/sphinx/etc/sphinx.conf
cp contrib/scripts/searchd /etc/init.d/
chmod 777 /etc/init.d/searchd
ln -s /etc/init.d/searchd /etc/init.d/S55searchd
sed -i -e 's/\/release\/search/\/opt\/sphinx\/bin/g' /etc/init.d/searchd
sed -i -e 's/\$BASE_PATH\/searchd.pid/\/opt\/sphinx\/var\/searchd.pid/g' /etc/init.d/searchd
sed -i -e 's/\$BASE_PATH\/sphinx.conf/\/opt\/sphinx\/etc\/sphinx.conf/g' /etc/init.d/searchd

/usr/sbin/useradd -r searchd
cd /opt/sphinx
chown -R searchd:searchd var

/etc/init.d/searchd start
ln -s /etc/init.d/searchd /etc/rc3.d/S41searchd

wall Sphinx Installed


#
# Setup PHP
#
cd /root/src/php*/
./configure --prefix=/opt/php5 --with-apxs2=/opt/apache/bin/apxs --with-config-file-path=/etc/ --with-gd --enable-shmop --enable-track-vars --enable-ftp --enable-sockets --enable-exif --enable-zip --enable-sysvsem --with-zlib --enable-sysvshm --enable-magic-quotes --with-jpeg-dir --with-png-dir --enable-mbstring --enable-embedded-mysqli=shared --with-curl --with-mcrypt --with-mysql=/opt/mysql --with-mysqli=/opt/mysql/bin/mysql_config 
# If you want imap support: use --with-imap --with-imap-ssl=/usr/include/openssl --with-kerberos
make -j 4
make install

wall PHP Installed