Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux centos7 Ultimate compilation and deployment LAMP Environment script domestic website download speed is fast

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

#! / bin/bash

# LAMP Ultimate deployment

Cat / dev/null

Mkdir / usr/local/apache & > / dev/null

Cd / usr/local/src

Echo "downloading Apache service, please wait a moment!"

Wget http://archive.apache.org/dist/apr/apr-1.6.5.tar.gz & > / dev/null

Wget http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz & > / dev/null

Wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.37.tar.gz & > / dev/null

If [$?-eq 0]

Then

Echo "download success"

Else

Echo "download failed"

Exit

Fi

Tar xf apr-1.6.5.tar.gz

Tar xf apr-util-1.6.1.tar.gz

Tar xf httpd-2.4.37.tar.gz

Echo "installing required dependency packages"

Yum-y install gcc gcc-c++ openssl openssl-devel expat-devel & > / dev/null

If [$?-eq 0]

Then

Echo "dependency package installed successfully"

Else

Echo "dependency package installation failed"

Exit

Fi

Cd / usr/local/src/apr-1.6.5/

Echo "is configuring and compiling and installing apr, please have a sip of water and wait a moment!"

. / configure-- prefix=/usr/local/apr/ & > / dev/null

Make & > / dev/null & & make install & > / dev/null

If [$?-eq 0]

Then

Echo "apr installed"

Else

Echo "apr installed failed"

Exit

Fi

Cd / usr/local/src/apr-util-1.6.1/

. / configure-- prefix=/usr/local/apr-util-- with-apr=/usr/local/apr/ & > / dev/null

Make & > / dev/null & & make install & > / dev/null

If [$?-eq 0]

Then

Echo "apr-util installed"

Else

Echo "apr-util installed failed"

Exit

Fi

Cd / usr/local/src/httpd-2.4.37/

Echo "configuring Apache"

. / configure-- prefix=/usr/local/apache/-- with-apr=/usr/local/apr/-- with-apr-util=/usr/local/apr-util/-- enable-so-- enable-ssl--enable-deflate=shared-- enable-expires=shared-- enable-rewrite=shared-- enable-static-support & > / dev/null

Make & > / dev/null & & make install & > / dev/null

If [$?-eq 0]

Then

Echo "Apache installed"

Else

Echo "Apache installed failed"

Exit

Fi

Cd / usr/local/apache/bin/

Echo ServerName www.fangxi.com > > / usr/local/apache/conf/httpd.conf

. / apachectl start

If [$?-eq 0]

Then

Echo "Apache installed successfully and started"

Else

Echo "Apache startup failed"

Exit

Fi

}

# install php

Install_php ()

{

Echo "installing php service"

Yum-y install php php-cli php-curl php-fpm php-intl php-mcryp php-mysql php-gd php-mbstring php-xml php-dom & > / dev/null

If [$?-eq 0]

Then

Echo "php installed successfully"

Else

Echo "php installation failed"

Exit

Fi

Systemctl start php-fpm & > / dev/null

If [$?-eq 0]

Then

Echo "php installed successfully"

Else

Echo "php installation failed"

Exit

Fi

}

# compile and install Mysql

Install_mysql ()

{

Echo "start installing mysql"

Echo "preparing compilation environment, wait a minute"

Yum-y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake & > / dev/null

If [$?-eq 0]

Then

Echo "compilation environment is ready"

Else

Echo "compilation environment preparation failed"

Exit

Fi

Echo "downloading the source package-just a moment, please"

Wget https://down.51cto.com/download.php?do=attachment&aid=3110021&k=26b650aaf1d2184d58d2570ac2f8d0bb&t=1568725722&c=1

Groupadd mysql

Useradd-r-g mysql-s / bin/nologin mysql

Tar xf mysql-boost-5.7.26.tar.gz

Cd mysql-5.7.26/

Echo "is under configuration, please have another drink of water and take a nap."

Cmake. \

-DWITH_BOOST=boost/boost_1_59_0/\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DSYSCONFDIR=/etc\

-DMYSQL_DATADIR=/usr/local/mysql/data\

-DINSTALL_MANDIR=/usr/share/man\

-DMYSQL_TCP_PORT=3306\

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock\

-DDEFAULT_CHARSET=utf8\

-DEXTRA_CHARSETS=all\

-DDEFAULT_COLLATION=utf8_general_ci\

-DWITH_READLINE=1\

-DWITH_SSL=system\

-DWITH_EMBEDDED_SERVER=1\

-DENABLED_LOCAL_INFILE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1 & > / dev/null

If [$?-eq 0]

Then

Echo "mysql configuration successful"

Else

Echo "mysql configuration failed"

Exit

Fi

Echo "- installing, compiling, installing Mysql please wait a moment -"

Make & > / dev/null & & make install / dev/null

If [$?-eq 0]

Then

Echo "mysql compilation and installation succeeded"

Else

Echo "mysql compilation installation failed"

Exit

Fi

Echo [mysqld] > / etc/my.cnf

Echo basedir=/usr/local/mysql > > / etc/my.cnf

Echo datadir=/usr/local/mysql/data > > / etc/my.cnf

Echo "mysql profile successed"

Cd / usr/local/mysql/

Mkdir mysql-files

Chown-R mysql.mysql / usr/local/mysql

Echo "- initializing Mysql, please wait a moment -"

/ usr/local/mysql/bin/mysqld-initialize-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data & > mima.txt

Mima=awk'/ password/ {print $NF} 'mima.txt

Echo "initial password is: $mima"

If [$?-eq 0]

Then

Echo "mysql initialization successful"

Else

Echo "mysql initialization failed"

Exit

Fi

Bin/mysql_ssl_rsa_setup-datadir=/usr/local/mysql/data

# encrypt the database

Cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld

Chkconfig-add mysqld

Chkconfig mysqld on

# add to boot startup item

Systemctl start mysqld

If [$?-eq 0]

Then

Echo "mysql started successfully"

Else

Echo "mysql startup failed"

Exit

Fi

Echo "export PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile

Source / etc/profile

Echo "- modify the initial database password -"

Read-p "Please enter the database password you want to set" new_mima

Mysqladmin-uroot-p$ {mima} password "$new_mima"

If [$?-eq 0]

Then

Echo "mysql initial password modified successfully, mysql deployment completed"

Else

Echo "mysql initial password modification failed"

Exit

Fi

}

While:

Do

Read-p "Please enter the parameter you want to select:" var

Case $var in

a)

Install_Apache

b)

Install_php

c)

Install_mysql

d)

Install_Apache

Install_php

Install_mysql

q)

Exit

*)

Printf "Please follow the options provided above to enter!!\ n"

Esac

Done

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report