#!/bin/bash
case "$1" in
apache)
echo "install apache"
cd /home
tar jxvf httpd-2.2.22.tar.bz2
cd /home/httpd-2.2.22
./configure --prefix=/usr/local/apache --enable-so
make && make install
;;
mysql)
echo "install mysql"
cd /home
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure
make
make install
groupadd mysql
useradd -g mysql mysql
cd /home
tar zxvf mysql-5.1.65.tar.gz
cd mysql-5.1.65
./configure --prefix=/usr/local/mysql --enable-assembler --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=complex --enable-local-infile --disable-shared --with-plugins=all --with-mysqld-user=mysql --with-pthread --enable-thread-safe-client
make
make install
;;
php)
ls /usr/local/ | grep apache
if [ $? -eq 0 ]
then
echo "install php"
cd /home
tar zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure --prefix=/usr/local/libxml2
make && make install
cd /home
tar jxvf php-5.3.13.tar.bz2
cd php-5.3.13
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2
make && make install
sed -i '167c DirectoryIndex index.html index.php' /usr/local/apache/conf/httpd.conf
sed -i '309a AddType application/x-httpd-php .php\nAddType application/x-httpd-php-source .phps' /usr/local/apache/conf/httpd.conf
echo '<?' >> /usr/local/apache/htdocs/index.php
echo 'phpinfo();' >> /usr/local/apache/htdocs/index.php
echo '?>' >> /usr/local/apache/htdocs/index.php
else
echo "install apache first"
cd /home
tar jxvf httpd-2.2.22.tar.bz2
cd /home/httpd-2.2.22
./configure --prefix=/usr/local/apache --enable-so
make && make install
echo "install php"
cd /home
tar zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure --prefix=/usr/local/libxml2
make && make install
cd /home
tar jxvf php-5.3.13.tar.bz2
cd /home/php-5.3.13
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2
make && make install
sed -i '167c DirectoryIndex index.html index.php' /usr/local/apache/conf/httpd.conf
sed -i '309a AddType application/x-httpd-php .php\nAddType application/x-httpd-php-source .phps' /usr/local/apache/conf/httpd.conf
echo '<?' >> /usr/local/apache/htdocs/index.php
echo 'phpinfo();' >> /usr/local/apache/htdocs/index.php
echo '?>' >> /usr/local/apache/htdocs/index.php
fi
;;
tomcat)
echo "install tomcat"
cd /home
tar zxvf jdk-7u5-linux-i586.tar.gz
cp -R /home/jdk1.7.0_05 /usr/local/jdk
echo 'JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME=/jre/lib' >> /etc/profile
echo 'PATH=$PATH:$JAVA_HOME/bin:$JAVA/jre/bin' >> /etc/profile
echo 'export JAVA_HOME CLASSPATH PATH' >> /etc/profile
source /etc/profile
cd /home
tar zxvf apache-tomcat-6.0.35.tar.gz
cp -R apache-tomcat-6.0.35 /usr/local/tomcat
cd /usr/local
echo 'export CATALINA_BASE=/usr/local/tomcat' >> ~/.bashrc
echo 'export CATALINA_HOME=/usr/local/tomcat' >> ~/.bashrc
echo 'export JAVA_HOME=/usr/local/jdk' >> ~/.bashrc
echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin' >> ~/.bashrc
cd /usr/local/tomcat/bin
./startup.sh
;;
all)
echo "install all apache php mysql tomcat"
cd /home
tar jxvf httpd-2.2.22.tar.bz2
cd /home/httpd-2.2.22
./configure --prefix=/usr/local/apache --enable-so
make && make install
cd /home
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure
make
make install
groupadd mysql
useradd -g mysql mysql
cd /home
tar zxvf mysql-5.1.65.tar.gz
cd mysql-5.1.65
./configure --prefix=/usr/local/mysql --enable-assembler --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=complex --enable-local-infile --disable-shared --with-plugins=all --with-mysqld-user=mysql --with-pthread --enable-thread-safe-client
make
make install
cd /usr/local/mysql
chgrp -R mysql .
./bin/mysql_install_db --user=mysql
chown -R mysql:mysql var
cd /home
tar zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure --prefix=/usr/local/libxml2
make && make install
cd /home
tar jxvf php-5.3.13.tar.bz2
cd php-5.3.13
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2
make && make install
sed -i '167c DirectoryIndex index.html index.php' /usr/local/apache/conf/httpd.conf
sed -i '309a AddType application/x-httpd-php .php\nAddType application/x-httpd-php-source .phps' /usr/local/apache/conf/httpd.conf
echo '<?' >> /usr/local/apache/htdocs/index.php
echo 'phpinfo();' >> /usr/local/apache/htdocs/index.php
echo '?>' >> /usr/local/apache/htdocs/index.php
cd /home
tar zxvf jdk-7u5-linux-i586.tar.gz
cp -R /home/jdk1.7.0_05 /usr/local/jdk
echo 'JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME=/jre/lib' >> /etc/profile
echo 'PATH=$PATH:$JAVA_HOME/bin:$JAVA/jre/bin' >> /etc/profile
echo 'export JAVA_HOME CLASSPATH PATH' >> /etc/profile
source /etc/profile
cd /home
tar zxvf apache-tomcat-6.0.35.tar.gz
cp -R apache-tomcat-6.0.35 /usr/local/tomcat
cd /usr/local
echo 'export CATALINA_BASE=/usr/local/tomcat' >> ~/.bashrc
echo 'export CATALINA_HOME=/usr/local/tomcat' >> ~/.bashrc
echo 'export JAVA_HOME=/usr/local/jdk' >> ~/.bashrc
echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin' >> ~/.bashrc
cd /usr/local/tomcat/bin
./startup.sh
;;
help)
cat <<help
apache - install apache only
mysql - install mysql only
php - install php only (if you didn't install apache, it will help you to install apache first)
tomcat - install tomcat only
all - install all(apache mysql php tomcat)
help
;;
*)
echo "Usage: $0 {apache|mysql|php|tomcat|all|help}"
exit 1
;;
esac
lnmp安装脚本
原创yuzifei123 博主文章分类:LNMP ©著作权
文章标签 lnmp apache php mysq 文章分类 MySQL 数据库
上一篇:linux网络相关配置
-
lnmp脚本
lnmp脚本
nginx php mysql