Linux shell实现一键安装LAMP(RPM包版本)

lamp.sh

#!/bin/bash
#一键部署lamp(rpm包版本)
#需提前配置好yum源

yum -y install httpd
yum -y install mariadb mariadb-devel mariadb-server
yum -y install php php-mysql

systemctl start httpd mariadb
systemctl enable httpd mariadb

安装

[root@elasticsearch ~]# sh lamp.sh 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-95.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-95.el7.centos for package: httpd-2.4.6-95.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-95.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-95.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-95.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-95.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
 Package                  Arch                Version                           Repository            Size
===========================================================================================================
Installing:
 httpd                    x86_64              2.4.6-95.el7.centos               CentOS7              2.7 M
Installing for dependencies:
 apr                      x86_64              1.4.8-7.el7                       CentOS7              104 k
 apr-util                 x86_64              1.5.2-6.el7                       CentOS7               92 k
 httpd-tools              x86_64              2.4.6-95.el7.centos               CentOS7               93 k
 mailcap                  noarch              2.1.41-2.el7                      CentOS7               31 k

Transaction Summary
===========================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
-----------------------------------------------------------------------------------------------------------
Total                                                                       12 MB/s | 3.0 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-7.el7.x86_64                                                                  1/5 
  Installing : apr-util-1.5.2-6.el7.x86_64                                                             2/5 
  Installing : httpd-tools-2.4.6-95.el7.centos.x86_64                                                  3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                                             4/5 
  Installing : httpd-2.4.6-95.el7.centos.x86_64                                                        5/5 
  Verifying  : httpd-tools-2.4.6-95.el7.centos.x86_64                                                  1/5 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                             2/5 
  Verifying  : apr-1.4.8-7.el7.x86_64                                                                  3/5 
  Verifying  : httpd-2.4.6-95.el7.centos.x86_64                                                        4/5 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                             5/5 

Installed:
  httpd.x86_64 0:2.4.6-95.el7.centos                                                                       

Dependency Installed:
  apr.x86_64 0:1.4.8-7.el7       apr-util.x86_64 0:1.5.2-6.el7  httpd-tools.x86_64 0:2.4.6-95.el7.centos 
  mailcap.noarch 0:2.1.41-2.el7 

Complete!
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> 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
--> Processing Dependency: openssl-devel(x86-64) for package: 1:mariadb-devel-5.5.68-1.el7.x86_64
---> Package mariadb-server.x86_64 1:5.5.68-1.el7 will be installed
--> Running transaction check
---> Package openssl-devel.x86_64 1:1.0.2k-19.el7 will be installed
--> Processing Dependency: zlib-devel(x86-64) for package: 1:openssl-devel-1.0.2k-19.el7.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-19.el7.x86_64
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.15.1-50.el7 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-50.el7 for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-50.el7.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-50.el7.x86_64
---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed
---> Package libkadm5.x86_64 0:1.15.1-50.el7 will be installed
---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-15.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
--> Running transaction check
---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-17.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:
 keyutils-libs-devel             x86_64             1.5.8-3.el7                  CentOS7              37 k
 krb5-devel                      x86_64             1.15.1-50.el7                CentOS7             273 k
 libcom_err-devel                x86_64             1.42.9-19.el7                CentOS7              32 k
 libkadm5                        x86_64             1.15.1-50.el7                CentOS7             179 k
 libselinux-devel                x86_64             2.5-15.el7                   CentOS7             187 k
 libsepol-devel                  x86_64             2.5-10.el7                   CentOS7              77 k
 libverto-devel                  x86_64             0.2.5-4.el7                  CentOS7              12 k
 openssl-devel                   x86_64             1:1.0.2k-19.el7              CentOS7             1.5 M
 pcre-devel                      x86_64             8.32-17.el7                  CentOS7             480 k
 zlib-devel                      x86_64             1.2.7-18.el7                 CentOS7              50 k

Transaction Summary
===========================================================================================================
Install  3 Packages (+10 Dependent packages)

Total download size: 24 M
Installed size: 116 M
Downloading packages:
-----------------------------------------------------------------------------------------------------------
Total                                                                       32 MB/s |  24 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libkadm5-1.15.1-50.el7.x86_64                                                          1/13 
  Installing : libsepol-devel-2.5-10.el7.x86_64                                                       2/13 
  Installing : libcom_err-devel-1.42.9-19.el7.x86_64                                                  3/13 
  Installing : pcre-devel-8.32-17.el7.x86_64                                                          4/13 
  Installing : libselinux-devel-2.5-15.el7.x86_64                                                     5/13 
  Installing : 1:mariadb-5.5.68-1.el7.x86_64                                                          6/13 
  Installing : zlib-devel-1.2.7-18.el7.x86_64                                                         7/13 
  Installing : libverto-devel-0.2.5-4.el7.x86_64                                                      8/13 
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                 9/13 
  Installing : krb5-devel-1.15.1-50.el7.x86_64                                                       10/13 
  Installing : 1:openssl-devel-1.0.2k-19.el7.x86_64                                                  11/13 
  Installing : 1:mariadb-devel-5.5.68-1.el7.x86_64                                                   12/13 
  Installing : 1:mariadb-server-5.5.68-1.el7.x86_64                                                  13/13 
  Verifying  : libselinux-devel-2.5-15.el7.x86_64                                                     1/13 
  Verifying  : 1:mariadb-devel-5.5.68-1.el7.x86_64                                                    2/13 
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                 3/13 
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                                                      4/13 
  Verifying  : zlib-devel-1.2.7-18.el7.x86_64                                                         5/13 
  Verifying  : 1:mariadb-server-5.5.68-1.el7.x86_64                                                   6/13 
  Verifying  : 1:mariadb-5.5.68-1.el7.x86_64                                                          7/13 
  Verifying  : pcre-devel-8.32-17.el7.x86_64                                                          8/13 
  Verifying  : 1:openssl-devel-1.0.2k-19.el7.x86_64                                                   9/13 
  Verifying  : libcom_err-devel-1.42.9-19.el7.x86_64                                                 10/13 
  Verifying  : krb5-devel-1.15.1-50.el7.x86_64                                                       11/13 
  Verifying  : libsepol-devel-2.5-10.el7.x86_64                                                      12/13 
  Verifying  : libkadm5-1.15.1-50.el7.x86_64                                                         13/13 

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:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7               krb5-devel.x86_64 0:1.15.1-50.el7                 
  libcom_err-devel.x86_64 0:1.42.9-19.el7                libkadm5.x86_64 0:1.15.1-50.el7                   
  libselinux-devel.x86_64 0:2.5-15.el7                   libsepol-devel.x86_64 0:2.5-10.el7                
  libverto-devel.x86_64 0:0.2.5-4.el7                    openssl-devel.x86_64 1:1.0.2k-19.el7              
  pcre-devel.x86_64 0:8.32-17.el7                        zlib-devel.x86_64 0:1.2.7-18.el7                  

Complete!
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> 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
---> 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 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 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:
 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 (+4 Dependent packages)

Total download size: 4.9 M
Installed size: 18 M
Downloading packages:
-----------------------------------------------------------------------------------------------------------
Total                                                                       19 MB/s | 4.9 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/6 
  Installing : php-common-5.4.16-48.el7.x86_64                                                         2/6 
  Installing : php-cli-5.4.16-48.el7.x86_64                                                            3/6 
  Installing : php-pdo-5.4.16-48.el7.x86_64                                                            4/6 
  Installing : php-mysql-5.4.16-48.el7.x86_64                                                          5/6 
  Installing : php-5.4.16-48.el7.x86_64                                                                6/6 
  Verifying  : php-cli-5.4.16-48.el7.x86_64                                                            1/6 
  Verifying  : php-pdo-5.4.16-48.el7.x86_64                                                            2/6 
  Verifying  : php-mysql-5.4.16-48.el7.x86_64                                                          3/6 
  Verifying  : libzip-0.10.1-8.el7.x86_64                                                              4/6 
  Verifying  : php-common-5.4.16-48.el7.x86_64                                                         5/6 
  Verifying  : php-5.4.16-48.el7.x86_64                                                                6/6 

Installed:
  php.x86_64 0:5.4.16-48.el7                        php-mysql.x86_64 0:5.4.16-48.el7                       

Dependency Installed:
  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!
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@elasticsearch ~]# 

验证

[root@elasticsearch ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2024-05-11 13:54:47 CST; 58s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 2539 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─2539 /usr/sbin/httpd -DFOREGROUND
           ├─2547 /usr/sbin/httpd -DFOREGROUND
           ├─2548 /usr/sbin/httpd -DFOREGROUND
           ├─2549 /usr/sbin/httpd -DFOREGROUND
           ├─2550 /usr/sbin/httpd -DFOREGROUND
           └─2551 /usr/sbin/httpd -DFOREGROUND

May 11 13:54:46 elasticsearch systemd[1]: Starting The Apache HTTP Server...
May 11 13:54:46 elasticsearch httpd[2539]: AH00558: httpd: Could not reliably determine the server's...sage
May 11 13:54:47 elasticsearch systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@elasticsearch ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2024-05-11 13:54:50 CST; 1min 11s ago
 Main PID: 2630 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─2630 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─2794 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/my...

May 11 13:54:48 elasticsearch mariadb-prepare-db-dir[2540]: MySQL manual for more instructions.
May 11 13:54:48 elasticsearch mariadb-prepare-db-dir[2540]: Please report any problems at http://maria...ra
May 11 13:54:48 elasticsearch mariadb-prepare-db-dir[2540]: The latest information about MariaDB is av.../.
May 11 13:54:48 elasticsearch mariadb-prepare-db-dir[2540]: You can find additional information about ...t:
May 11 13:54:48 elasticsearch mariadb-prepare-db-dir[2540]: http://dev.mysql.com
May 11 13:54:48 elasticsearch mariadb-prepare-db-dir[2540]: Consider joining MariaDB's strong and vibr...y:
May 11 13:54:48 elasticsearch mariadb-prepare-db-dir[2540]: https://mariadb.org/get-involved/
May 11 13:54:48 elasticsearch mysqld_safe[2630]: 240511 13:54:48 mysqld_safe Logging to '/var/log/mar...g'.
May 11 13:54:48 elasticsearch mysqld_safe[2630]: 240511 13:54:48 mysqld_safe Starting mysqld daemon w...sql
May 11 13:54:50 elasticsearch systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@elasticsearch ~]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值