Shell Automation Installation Lamp

Source: Internet
Author: User
Tags bz2 install php php server php define

(a) Installation ideas

(1) Source code compile Apache WEB Service

(2) Source code compile MySQL DB service


(3) Source code compiled PHP WEB service


(4) Lamp Source Integration +php page creation


(5) Optimization of shell scripts, introduction of variables, conditional judgment


(ii) Case script

#!/bin/bash

#auto Install LAMP

#By author Daqi

#auto_lamp_config


#Apache definne Path variable

h_files=httpd-2.2.34.tar.bz2

h_files_dir=httpd-2.2.34

h_url=http://mirrors.cnnic.cn/apache/httpd/

h_prefix=/usr/local/apache2/


#MySQL Define PATH variable

M_files=mysql-5.5.20.tar.gz

m_files_dir=mysql-5.5.20

m_url=http://down1.chinaunix.net/distfiles/

m_prefix=/usr/local/mysql/


#PHP Define PATH variable

p_files=php-5.3.28.tar.bz2

p_files_dir=php-5.3.28

p_url=http://mirrors.sohu.com/php/

p_prefix=/usr/local/php5/


If [$#-eq 0];then

Echo-e "\033[36m---------------------------\033[0m"

Echo-e "\033[36mplease Select Install menu:\033[0m"

echo "1) Official download httpd file package."

echo "2) official download MySQL file package."

echo "3) Official download PHP file package."

echo "4) Integrated lamp"

Echo-e "\033[36m---------------------------\033[0m"

Exit

Fi


If [$1-ne 1-a $1-ne 2-a $1-ne 3-a $1-ne 4];then

Echo-e "\033[36m---------------------------\033[0m"

Echo-e "\033[36mplease Select Install menu:\033[0m"

echo "1) Official download httpd file package."

echo "2) official download MySQL file package."

echo "3) Official download PHP file package."

echo "4) Integrated lamp"

Echo-e "\033[36m---------------------------\033[0m"

Exit

Fi



#Install httpd Web Server

if [$1-eq 1];then

Wget-c $H _url/$H _files && tar-jxvf $H _files && cd $H _files_dir &&./configure--prefix= $H _prefix

Make && make install

Exit

Fi


#Install Mysql DB Server

if [$1-eq 2];then

Useradd-s/sbin/nologin MySQL

Wget-c $M _url/$M _files && tar-xzvf $M _files && cd $M _files_dir &&yum install cmake-y; cmake. -dcmake_install_prefix= $M _prefix \

-dmysql_unix_addr=/tmp/mysql.sock \

-dmysql_datadir=/data/mysql \

-DSYSCONFDIR=/ETC \

-dmysql_user=mysql \

-dmysql_tcp_port=3306 \

-dwith_xtradb_storage_engine=1 \

-dwith_innobase_storage_engine=1 \

-dwith_partition_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

-dwith_myisam_storage_engine=1 \

-dwith_readline=1 \

-denabled_local_infile=1 \

-dwith_extra_charsets=1 \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-dextra_charsets=all \

-dwith_big_tables=1 \

-dwith_debug=0

Make && make install

/BIN/CP support-files/my-small.cnf/etc/my.cnf

/BIN/CP Support-files/mysql.server/etc/init.d/mysqld

chmod +x/etc/init.d/mysqld

Chkconfig--add mysqld

Chkconfig mysqld on

Make && make install

Exit

Fi


#Install PHP Server

if [$1-eq 3];then

Wget-c $P _url/$P _files && tar-jxvf $P _files && cd $P _files_dir &&./configure--prefix= $P _prefix --with-config-file-path= $P _prefix/etc--with-mysql= $M _prefix--with-apxs2= $H _prefix/bin/apxs

Make zend_extra_libs= '-liconv ' && make install

Exit

Fi


#Install Lamp_config

if [$1-eq 4];then

echo "AddType application/x-httpd-php. php" >> $H _prefix/conf/httpd.conf

$H _prefix/bin/apachectl Restart

Cat > $H _prefix/htdocs/index.php <<eof

<?php

Phpinfo ();

?>

Eof

Fi


Shell Automation Installation Lamp

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.