Created
August 8, 2012 15:27
-
-
Save wdfsinap/3295922 to your computer and use it in GitHub Desktop.
LiteSpeed+Nginx+Mysql+PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin | |
export PATH | |
cur_dir=$(pwd) | |
#set up email | |
email="root@localhost.com" | |
echo "Please input email:" | |
printf "(Default email: root@localhost.com):" | |
read email | |
echo "" | |
if [ "$email" = "" ]; then | |
email="root@localhost.com" | |
fi | |
echo "=========================================================================" | |
echo email="$email" | |
echo "=========================================================================" | |
#set up username | |
username="admin" | |
echo "Please input username:" | |
printf "(Default username: admin):" | |
read username | |
echo "" | |
if [ "$username" = "" ]; then | |
username="admin" | |
fi | |
echo "=========================================================================" | |
echo username="$username" | |
echo "=========================================================================" | |
#set up password | |
password="admin123" | |
echo "Please input Litespeed and MySQL password(AT LEAST 6 CHARACTERS!!!!!):" | |
printf "(Default password: admin123):" | |
read password | |
echo "" | |
if [ "$password" = "" ]; then | |
password="admin123" | |
fi | |
echo "=========================================================================" | |
echo password="$password" | |
echo "=========================================================================" | |
#Synchronization time | |
rm -rf /etc/localtime | |
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | |
yum install -y ntp | |
ntpdate -d cn.pool.ntp.org | |
date | |
#Install packeages | |
rpm -qa|grep httpd | |
rpm -e httpd | |
rpm -qa|grep mysql | |
rpm -e mysql | |
rpm -qa|grep php | |
rpm -e php | |
yum -y remove httpd* mysql* php* | |
centosversion=$(cat /etc/redhat-release | grep -o [0-9] | sed 1q) | |
if [ "$centosversion" = "5" ];then | |
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/epel-release-5-4.noarch.rpm | |
else | |
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/epel-release-5-4.noarch.rpm | |
fi | |
bit=$(getconf LONG_BIT) | |
if [ $bit = "64" ]; then | |
yum -y install glibc expect flex re2c bison mysql-server mysql-devel gcc automake mhash-devel expect ruby autoconf213 libtool gcc-c++ libjpeg-devel libpng-devel libxml2-devel curl curl-devel libmcrypt-devel freetype-devel patch make zlib-devel libtool-ltdl-devel | |
else | |
yum -y install flex expect re2c bison mysql-server mysql-devel gcc automake mhash-devel expect ruby autoconf213 libtool gcc-c++ libjpeg-devel libpng-devel libxml2-devel curl curl-devel libmcrypt-devel freetype-devel patch make zlib-devel libtool-ltdl-devel | |
fi | |
echo "==================Install LiteSpeed Now===================" | |
#Download litespeed | |
cd /root | |
wget -c https://llnmp.googlecode.com/files/lsws-4.1.13.tar.gz | |
tar zxf lsws-4.1.13.tar.gz | |
cd lsws-4.1.13 | |
chmod +x install.sh | |
sed -i '/license/d' install.sh | |
#Install Litespeed | |
expect -c " | |
set timeout 1 | |
spawn /root/lsws-4.1.13/install.sh | |
expect \"5RetHEgU10\" | |
send \"\r\" | |
expect \"5RetHEgU11\" | |
send \"$username\r\" | |
expect \"5RetHEgU12\" | |
send \"$password\r\" | |
expect \"5RetHEgU13\" | |
send \"$password\r\" | |
expect \"5RetHEgU14\" | |
send \"$email\r\" | |
expect \"5RetHEgU1\" | |
send \"\r\" | |
expect \"5RetHEgU2\" | |
send \"\r\" | |
expect \"5RetHEgU3\" | |
send \"8088\r\" | |
expect \"5RetHEgU4\" | |
send \"\r\" | |
expect \"5RetHEgU5\" | |
send \"Y\r\" | |
expect \"5RetHEgU6\" | |
send \"\r\" | |
expect \"5RetHEgU7\" | |
send \"N\r\" | |
expect \"5RetHEgU8\" | |
send \"Y\r\" | |
expect \"5RetHEgU9\" | |
send \"Y\r\" | |
" | |
export PHP_AUTOCONF=/usr/bin/autoconf-2.13 | |
export PHP_AUTOHEADER=/usr/bin/autoheader-2.13 | |
mkdir /usr/local/lsws/phpbuild | |
cd /root | |
wget -c https://llnmp.googlecode.com/files/php-5.2.17.tar.gz | |
wget -c http://www.litespeedtech.com/packages/lsapi/php-litespeed-5.5.tgz | |
wget -c http://files.directadmin.com/services/custombuild/php-5.2.17-mail-header.patch | |
tar zxf php-5.2.17.tar.gz | |
tar zxf php-litespeed-5.5.tgz | |
cd /root/php-5.2.17 | |
patch -p1 < /root/php_52_mail_header_patch | |
mv /root/litespeed /root/php-5.2.17/sapi/litespeed/ | |
cd /root | |
mv php-5.2.17 /usr/local/lsws/phpbuild | |
cd /usr/local/lsws/phpbuild/php-5.2.17 | |
touch ac* | |
rm -rf autom4te.* | |
./buildconf --force | |
bit=$(getconf LONG_BIT) | |
if [ "$bit" = "64" ]; then | |
./configure '--prefix=/usr/local/lsws/lsphp5' '--with-libdir=lib64' '--with-pdo-mysql' '--with-mysql' '--with-mysqli' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--with-litespeed' '--enable-inline-optimization' '--with-curl' '--with-curlwrappers' '--with-mcrypt' '--with-mhash' '--with-mime-magic' '--with-openssl' '--with-freetype-dir=/usr/lib' '--with-jpeg-dir=/usr/lib' '--enable-bcmath' | |
else | |
./configure '--prefix=/usr/local/lsws/lsphp5' '--with-pdo-mysql' '--with-mysql' '--with-mysqli' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--with-litespeed' '--enable-inline-optimization' '--with-curl' '--with-curlwrappers' '--with-mcrypt' '--with-mhash' '--with-mime-magic' '--with-openssl' '--with-freetype-dir=/usr/lib' '--with-jpeg-dir=/usr/lib' '--enable-bcmath' | |
fi | |
make clean | |
echo `date` | |
make | |
make -k install | |
cd /usr/local/lsws/fcgi-bin | |
if [ -e "lsphp-5.2.17" ] ; then | |
mv lsphp-5.2.17 lsphp-5.2.17.bak | |
fi | |
cp /usr/local/lsws/phpbuild/php-5.2.17/sapi/litespeed/php lsphp-5.2.17 | |
ln -sf lsphp-5.2.17 lsphp5 | |
chown -R lsadm:lsadm /usr/local/lsws/phpbuild/php-5.2.17 | |
cp -f /usr/local/lsws/phpbuild/php-5.2.17/php.ini-dist /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i '/extension_dir/d' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i '/sendmail_path/d' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i '/smtp_port/a\sendmail_path = \/usr\/sbin\/sendmail -t\n' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/;date.timezone =/date.timezone = PRC/g' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /usr/local/lsws/lsphp5/lib/php.ini | |
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen/g' /usr/local/lsws/lsphp5/lib/php.ini | |
mkdir -p /usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613 | |
/etc/init.d/lsws restart | |
echo "=====================LiteSpeed Installed Successfully===================" | |
#install ZendOptimizer | |
if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then | |
wget -c https://llnmp.googlecode.com/files/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz | |
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz | |
mkdir -p /usr/local/zend/ | |
cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/ | |
else | |
wget -c https://llnmp.googlecode.com/files/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz | |
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz | |
mkdir -p /usr/local/zend/ | |
cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/ | |
fi | |
cat >>/usr/local/lsws/lsphp5/lib/php.ini<<EOF | |
;eaccelerator | |
;ionCube | |
[Zend Optimizer] | |
zend_optimizer.optimization_level=1 | |
zend_extension="/usr/local/zend/ZendOptimizer.so" | |
EOF | |
#Mysql Setting | |
/etc/init.d/mysqld start | |
mysqladmin -u root password $password | |
mysql_version=$(mysql -V | awk '{ print $5 }' | awk -F "." '{print $1"."$2}') | |
if [ "$mysql_version" = "5.1" ]; then | |
mysql_subversion=$(mysql -V | awk '{ print $3 }' | awk -F "." '{print $2}') | |
if [ "$mysql_subversion" -ge 12 ];then | |
sed -i '/\[mysqld\]/a\skip-locking\nskip-innodb' /etc/my.cnf | |
else | |
sed -i '/\[mysqld\]/a\skip-locking\nskip-bdb\nskip-innodb' /etc/my.cnf | |
fi | |
else | |
sed -i '/\[mysqld\]/a\skip-locking\nskip-bdb\nskip-innodb' /etc/my.cnf | |
fi | |
/etc/init.d/mysqld restart | |
chkconfig --level 345 mysqld on | |
echo "===================Install Nginx Now=============================" | |
# nginx install | |
cd $cur_dir | |
wget -c https://llnmp.googlecode.com/files/pcre-8.12.tar.gz | |
tar zxvf pcre-8.12.tar.gz | |
cd pcre-8.12/ | |
./configure | |
make && make install | |
cd ../ | |
ldconfig | |
wget -c http://nginx.org/download/nginx-1.2.2.tar.gz | |
tar zxvf nginx-1.2.2.tar.gz | |
cd nginx-1.2.2/ | |
groupadd www | |
useradd -g www www | |
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 | |
make && make install | |
cd ../ | |
rm -f /usr/local/nginx/conf/nginx.conf | |
cd $cur_dir | |
cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf | |
cp conf/proxy.conf /usr/local/nginx/conf/proxy.conf | |
mkdir -p /home/wwwroot | |
cp conf/p.php /home/wwwroot/p.php | |
cp conf/index.html /home/wwwroot/index.html | |
cp conf/phpinfo.php /home/wwwroot/phpinfo.php | |
mkdir -p /usr/local/nginx/conf/servers | |
cp conf/init.d.nginx /etc/init.d/nginx | |
chmod +x /etc/init.d/nginx | |
chkconfig --level 345 nginx on | |
detect_ip () { | |
YOURIP=`hostname -i`; | |
primaryaddr1=`/sbin/ifconfig eth0|grep 'inet addr'|cut -d: -f2|cut -d" " -f1` | |
primaryaddr2=`/sbin/ifconfig eth1|grep 'inet addr'|cut -d: -f2|cut -d" " -f1` | |
primaryaddr3=`/sbin/ifconfig venet0:0|grep 'inet addr'|cut -d: -f2|cut -d" " -f1` | |
if [ $primaryaddr1 ]; then | |
#echo "ip1 = $primaryaddr1"; | |
YOURIP=$primaryaddr1; | |
sed --in-place -e 's/venet0:0/eth0/g' /etc/webmin/virtual-server/config | |
return 0; | |
elif [ $primaryaddr2 ]; then | |
#echo "ip2 = $primaryaddr2"; | |
YOURIP=$primaryaddr2; | |
sed --in-place -e 's/venet0:0/eth1/g' /etc/webmin/virtual-server/config | |
return 0; | |
elif [ $primaryaddr3 ]; then | |
#echo "ip3=$primaryaddr3"; | |
YOURIP=$primaryaddr3; | |
return 0; | |
fi | |
return 0; | |
} | |
detect_ip; | |
cat >>/usr/local/nginx/conf/servers/default.conf <<EOF | |
server | |
{ | |
listen 80; | |
server_name ${YOURIP}; | |
index index.html index.htm index.php; | |
root /home/wwwroot; | |
include /usr/local/nginx/conf/proxy.conf; | |
location / { | |
location ~ .*\.(php|php5)?$ { | |
index index.php; | |
root /home/wwwroot; | |
proxy_pass http://${YOURIP}:8088; | |
} | |
if ( !-e \$request_filename) { | |
proxy_pass http://${YOURIP}:8088; | |
} | |
location ~* \.(jpg|jpeg|gif|png|swf|htm|html)$ { | |
if (-f \$request_filename) { | |
root /home/wwwroot; | |
expires 30d; | |
break; | |
} | |
} | |
location ~* \.(js|css)$ { | |
if (-f \$request_filename) { | |
root /home/wwwroot; | |
expires 1d; | |
break; | |
} | |
} | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
} | |
EOF | |
mkdir -p /home/wwwroot/conf | |
cat >>/home/wwwroot/conf/vhost.xml <<EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<virtualHostConfig> | |
<docRoot>/home/wwwroot</docRoot> | |
<adminEmails></adminEmails> | |
<enableGzip></enableGzip> | |
</virtualHostConfig> | |
EOF | |
sed -e "/\/vhostMapList/i\\<vhostMap\>\n\<vhost\>${YOURIP}\<\/vhost\>\n\<domain\>${YOURIP}\<\/domain\>\n\<\/vhostMap\>" -i /usr/local/lsws/conf/httpd_config.xml | |
sed -e "/\/virtualHostList/i\\<virtualHost\>\n\<name\>${YOURIP}\<\/name\>\n\<vhRoot\>\/home\/wwwroot\<\/vhRoot\>\n\<configFile\>\/home\/wwwroot\/conf\/vhost.xml\<\/configFile\>\n\<note\>\<\/note\>\n\<allowSymbolLink\>0\<\/allowSymbolLink\>\n\<enableScript\>1\<\/enableScript\>\n\<restrained\>1\<\/restrained\>\n\<maxKeepAliveReq\>50\<\/maxKeepAliveReq\>\n\<smartKeepAlive\>\<\/smartKeepAlive\>\n\<setUIDMode\>0\<\/setUIDMode\>\n\<staticReqPerSec\>10\<\/staticReqPerSec\>\n\<dynReqPerSec\>10\<\/dynReqPerSec\>\n\<outBandwidth\>10\<\/outBandwidth\>\n\<inBandwidth\>10\<\/inBandwidth\>\n\<\/virtualHost\>" -i /usr/local/lsws/conf/httpd_config.xml | |
echo "================Nginx Installed successfully=======================================" | |
#phpmyadmin | |
echo "=================Install phpMyadmin Now=========================" | |
wget -c https://llnmp.googlecode.com/files/phpmyadmin-latest.tar.gz | |
tar zxvf phpmyadmin-latest.tar.gz | |
mv phpMyAdmin-3.4.8-all-languages /home/wwwroot/phpmyadmin/ | |
chmod 755 -R /home/wwwroot/phpmyadmin/ | |
chown www:www -R /home/wwwroot/ | |
echo "=================phpMyadmin Installed completely===============" | |
/etc/init.d/lsws restart | |
/etc/init.d/nginx start | |
echo "=========================================================================" | |
echo "Congratulations! LLNMP is installed successfully." | |
echo "Your LiteSpeed webmin address is http://${YOURIP}:7080" | |
echo "Your Nginx index page is : http://${YOURIP}/index.html" | |
echo "=========================================================================" | |
echo "For more information please visit http://vpssh.org" | |
echo "=========================================================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment