lamp.sh
#!/bin/bash
# 安装 LAMP 环境(yum 版本)
# 本脚本适用于 RHEL7(RHEL6 中数据库为 mysql)
yum makecache &>/dev/null
num=$(yum repolist | awk '/repolist/{print $2}' | sed 's/,//')
if [ $num -gt 0 ];then
yum -y install httpd
yum -y install mariadb mariadb-server mariadb-devel
yum -y install php php-mysql
else
echo "Please configure yum..."
fi
验证:
[root@logstash ~]# sh lamp.sh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================
Package Arch Version Repository Size
===========================================================================================================
Installing:
httpd x86_64 2.4.6-99.el7.centos.1 updates 2.7 M
Installing for dependencies:
httpd-tools x86_64 2.4.6-99.el7.centos.1 updates 94 k
Transaction Summary
===========================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 2.8 M
Installed size: 9.5 M
Downloading packages:
(1/2): httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm | 94 kB 00:00:00
httpd-2.4.6-99.el7.centos.1.x8 FAILED kB/s | 2.6 MB 00:00:51 ETA
......
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.68-1.el7 will be installed
---> Package mariadb-devel.x86_64 1:5.5.68-1.el7 will be installed
---> Package mariadb-server.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
mariadb x86_64 1:5.5.68-1.el7 CentOS7 8.8 M
mariadb-devel x86_64 1:5.5.68-1.el7 CentOS7 757 k
mariadb-server x86_64 1:5.5.68-1.el7 CentOS7 11 M
Installing for dependencies:
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 CentOS7 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 CentOS7 57 k
perl-DBD-MySQL x86_64 4.023-6.el7 CentOS7 140 k
perl-DBI x86_64 1.627-4.el7 CentOS7 802 k
perl-Data-Dumper x86_64 2.145-3.el7 CentOS7 47 k
perl-IO-Compress noarch 2.061-2.el7 CentOS7 260 k
perl-Net-Daemon noarch 0.48-5.el7 CentOS7 51 k
perl-PlRPC noarch 0.2020-14.el7 CentOS7 36 k
Transaction Summary
=============================================================================================================================================================
Install 3 Packages (+8 Dependent packages)
Total download size: 22 M
Installed size: 114 M
Downloading packages:
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 41 MB/s | 22 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 1/11
Installing : perl-Net-Daemon-0.48-5.el7.noarch 2/11
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 3/11
Installing : 1:mariadb-5.5.68-1.el7.x86_64 4/11
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 5/11
Installing : perl-IO-Compress-2.061-2.el7.noarch 6/11
Installing : perl-PlRPC-0.2020-14.el7.noarch 7/11
Installing : perl-DBI-1.627-4.el7.x86_64 8/11
Installing : perl-DBD-MySQL-4.023-6.el7.x86_64 9/11
Installing : 1:mariadb-server-5.5.68-1.el7.x86_64 10/11
Installing : 1:mariadb-devel-5.5.68-1.el7.x86_64 11/11
Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 1/11
Verifying : 1:mariadb-devel-5.5.68-1.el7.x86_64 2/11
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 3/11
Verifying : 1:mariadb-server-5.5.68-1.el7.x86_64 4/11
Verifying : perl-DBD-MySQL-4.023-6.el7.x86_64 5/11
Verifying : 1:mariadb-5.5.68-1.el7.x86_64 6/11
Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 7/11
Verifying : perl-Net-Daemon-0.48-5.el7.noarch 8/11
Verifying : perl-DBI-1.627-4.el7.x86_64 9/11
Verifying : perl-IO-Compress-2.061-2.el7.noarch 10/11
Verifying : perl-PlRPC-0.2020-14.el7.noarch 11/11
Installed:
mariadb.x86_64 1:5.5.68-1.el7 mariadb-devel.x86_64 1:5.5.68-1.el7 mariadb-server.x86_64 1:5.5.68-1.el7
Dependency Installed:
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7
perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7
Complete!
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package php.x86_64 0:5.4.16-48.el7 will be installed
--> Processing Dependency: php-common(x86-64) = 5.4.16-48.el7 for package: php-5.4.16-48.el7.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.4.16-48.el7 for package: php-5.4.16-48.el7.x86_64
--> Processing Dependency: httpd-mmn = 20120211x8664 for package: php-5.4.16-48.el7.x86_64
--> Processing Dependency: httpd for package: php-5.4.16-48.el7.x86_64
---> Package php-mysql.x86_64 0:5.4.16-48.el7 will be installed
--> Processing Dependency: php-pdo(x86-64) = 5.4.16-48.el7 for package: php-mysql-5.4.16-48.el7.x86_64
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.x86_64
---> Package php-cli.x86_64 0:5.4.16-48.el7 will be installed
---> Package php-common.x86_64 0:5.4.16-48.el7 will be installed
--> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-48.el7.x86_64
---> Package php-pdo.x86_64 0:5.4.16-48.el7 will be installed
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 will be installed
---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
php x86_64 5.4.16-48.el7 CentOS7 1.4 M
php-mysql x86_64 5.4.16-48.el7 CentOS7 102 k
Installing for dependencies:
httpd x86_64 2.4.6-99.el7.centos.1 updates 2.7 M
httpd-tools x86_64 2.4.6-99.el7.centos.1 updates 94 k
libzip x86_64 0.10.1-8.el7 CentOS7 48 k
php-cli x86_64 5.4.16-48.el7 CentOS7 2.7 M
php-common x86_64 5.4.16-48.el7 CentOS7 565 k
php-pdo x86_64 5.4.16-48.el7 CentOS7 99 k
Transaction Summary
=============================================================================================================================================================
Install 2 Packages (+6 Dependent packages)
Total size: 7.7 M
Total download size: 7.6 M
Installed size: 27 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
httpd-2.4.6-99.el7.centos.1.x86_64.rpm | 2.7 MB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 12 MB/s | 7.6 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libzip-0.10.1-8.el7.x86_64 1/8
Installing : php-common-5.4.16-48.el7.x86_64 2/8
Installing : php-cli-5.4.16-48.el7.x86_64 3/8
Installing : php-pdo-5.4.16-48.el7.x86_64 4/8
Installing : httpd-tools-2.4.6-99.el7.centos.1.x86_64 5/8
Installing : httpd-2.4.6-99.el7.centos.1.x86_64 6/8
Installing : php-5.4.16-48.el7.x86_64 7/8
Installing : php-mysql-5.4.16-48.el7.x86_64 8/8
Verifying : httpd-tools-2.4.6-99.el7.centos.1.x86_64 1/8
Verifying : php-cli-5.4.16-48.el7.x86_64 2/8
Verifying : php-pdo-5.4.16-48.el7.x86_64 3/8
Verifying : httpd-2.4.6-99.el7.centos.1.x86_64 4/8
Verifying : php-mysql-5.4.16-48.el7.x86_64 5/8
Verifying : libzip-0.10.1-8.el7.x86_64 6/8
Verifying : php-common-5.4.16-48.el7.x86_64 7/8
Verifying : php-5.4.16-48.el7.x86_64 8/8
Installed:
php.x86_64 0:5.4.16-48.el7 php-mysql.x86_64 0:5.4.16-48.el7
Dependency Installed:
httpd.x86_64 0:2.4.6-99.el7.centos.1 httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 libzip.x86_64 0:0.10.1-8.el7 php-cli.x86_64 0:5.4.16-48.el7
php-common.x86_64 0:5.4.16-48.el7 php-pdo.x86_64 0:5.4.16-48.el7
Complete!
[root@logstash ~]#