In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about shell script how to install LAMP and LNMP scripts with one click, the editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.
What the script needs to pay attention to:
1. Script is suitable for CentOS system above 6.5. clean system. If you have installed other environments, you need to modify the content of the script.
2. The script is applicable to: apache 2.4.x version; mysql5.5.x version or above; php5.5.x version or above
3. Mysql, php, apache and nginx installation packages should be downloaded to the / usr/local/src directory in advance. If the name is not correct, you need to change the package name in the script.
The version installed by the script is as follows. If you need a different name, please modify the software installation package name and the corresponding directory name.
Httpd-2.4.7.tar.gz 、 mysql-5.6.25.tar.gz 、 nginx-1.6.2.tar.gz 、 php-5.6.8.tar.gz
4. The script does not add judgment, and the environment is set as a clean system.
The script reads as follows:
#! / bin/bash
# written by mofansheng @ 2015-11-06
# one key install LAMP or LNMP scripts; apply to apache 2.4.x,mysql 5.6.x,nginx 1.6.x
. / etc/init.d/functions
# check the results of the command execution
Function check_ok () {
If [$?-eq 0]
Then
Continue
Else
Echo "please check error"
Exit
Fi
}
Function yum_update () {
# set yum repos
Echo "= update yum repos,it will take serval mintinues==="
Yum install wget-y
Mv / etc/yum.repos.d/CentOS-Base.repo / etc/yum.repos.d/CentOS-Base.repo.bak
Wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo & > / dev/null
Wget-O / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo & > / dev/null
Yum clean all & > / dev/null
Yum makecache & > / dev/null
Check_ok
Action "yum repos update is ok" / bin/true
}
Function yum_depend () {
# install dependencies packages
Yum install wget gcc gcc-c++ make re2c curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel zlib zlib-devel openssl openssl-devel freetype freetype-devel gd gd-devel perl perl-devel ncurses ncurses-devel bison bison-devel libtool gettext gettext-devel cmake bzip2 bzip2-devel pcre pcre-devel-y
}
Function install_mysql () {
Echo "mysql5.6.25 will be installed,please be patient"
Cd / usr/local/src
Tar-zxf mysql-5.6.25.tar.gz
Cd mysql-5.6.25
Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock-DSYSCONFDIR=/etc-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1-DMYSQL_TCP_PORT=3306-DENABLED_LOCAL_INFILE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DEXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci
Check_ok
Make & & make install
Check_ok
Useradd-M-s / sbin/nologin mysql
Mkdir-p / data/mysql
Chown-R mysql:mysql / data/mysql/
Chown-R mysql:mysql / usr/local/mysql/
Check_ok
Cd / usr/local/mysql/scripts/
. / mysql_install_db-- basedir=/usr/local/mysql/-- datadir=/data/mysql/-- user=mysql
Check_ok
/ bin/cp / usr/local/mysql/my.cnf / etc/my.cnf
Sed-I'/ ^\ [mysqld\] $/ a\ user = mysql\ ndatadir = / data/mysql\ ndefault_storage_engine = InnoDB\ n'/ etc/my.cnf
Check_ok
Cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld
Sed-I's # ^ datadir=#datadir=/data/mysql#' / etc/init.d/mysqld
Sed-I's # ^ basedir=#basedir=/usr/local/mysql#' / etc/init.d/mysqld
Service mysqld start
Chkconfig-add mysqld
Chkconfig mysqld on
Check_ok
Iptables-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT
/ etc/init.d/iptables save
Check_ok
Echo "export PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile
Source / etc/profile
Check_ok
}
Function install_apache () {
Echo "apache2.4.7 will be installed,please be patient"
Cd / usr/local/src
Wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.gz
Wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz
Check_ok
Tar zxf apr-1.5.2.tar.gz
Cd apr-1.5.2
. / configure-- prefix=/usr/local/apr
Check_ok
Make & & make install
Check_ok
Cd / usr/local/src
Tar zxf apr-util-1.5.4.tar.gz
Cd apr-util-1.5.4
. / configure-prefix=/usr/local/apr-util-with-apr=/usr/local/apr
Check_ok
Make & & make install
Check_ok
Cd / usr/local/src
Tar zxf httpd-2.4.7.tar.gz
/ bin/cp-r apr-1.5.2 / usr/local/src/httpd-2.4.7/srclib/apr
/ bin/cp-r apr-util-1.5.4 / usr/local/src/httpd-2.4.7/srclib/apr-util
Cd httpd-2.4.7
/ configure-- prefix=/usr/local/apache2-- with-apr=/usr/local/apr-- with-apr-util=/usr/local/apr-util/-- with-pcre-- enable-mods-shared=most-- enable-so-- with-included-apr
Check_ok
Make & & make install
Check_ok
Echo "export PATH=$PATH:/usr/local/apache2/bin" > > / etc/profile
Source / etc/profile
Check_ok
Iptables-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 80-j ACCEPT
/ etc/init.d/iptables save
Check_ok
/ usr/local/apache2/bin/apachectl
Check_ok
}
Function install_php () {
Echo "php5.6.8 will be installed,please be patient"
Cd / usr/local/src
Tar zxf php-5.6.8.tar.gz
Cd php-5.6.8
/ configure-- prefix=/usr/local/php-- with-apxs2=/usr/local/apache2/bin/apxs-- with-config-file-path=/usr/local/php/etc-- with-mysql=/usr/local/mysql-- with-libxml-dir-- with-gd-- with-jpeg-dir-- with-png-dir-- with-freetype-dir-- with-iconv-dir-- with-zlib-dir-- with-bz2-- with-openssl-- with-mcrypt-- enable -soap-enable-gd-native-ttf-- enable-mbstring-- enable-sockets-- enable-exif-- disable-ipv6
Check_ok
Make & & make install
Check_ok
Cp / usr/local/src/php-5.6.8/php.ini-production / usr/local/php/etc/php.ini
Sed-I's # ^; date.timezone= # date.timezone=Asia/Shanghai#' / usr/local/php/etc/php.ini
Check_ok
}
Function set_lamp () {
Sed-I'/ AddType application\ / x-gzip .gz .tgz / a\ AddType application/x-httpd-php .php\ n'/ usr/local/apache2/conf/httpd.conf
Sed-I 's#index.html#index.html index.php#' / usr/local/apache2/conf/httpd.conf
Sed-I'/ # ServerName www.example.com:80/a\ ServerName localhost:80\ n'/ usr/local/apache2/conf/httpd.conf
Check_ok
Cat > > / usr/local/apache2/htdocs/test.php
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.