如何用脚本安装LAMP

#!/bin/bash
systemctl stop firewalld
setenforce 0
sed -i '2s/'$BOOTPROTO=none'/'$BOOTPROTO=static'/' $vim /etc/sysconfig/network-scripts/ifcfg-ens33
sed -i '2s/'$BOOTPROTO=dhcp'/'$BOOTPROTO=static'/' $vim /etc/sysconfig/network-scripts/ifcfg-ens33
sed -i '17s/'$ONBOOT=no'/'$ONBOOT=yes'/' $vim /etc/sysconfig/network-scripts/ifcfg-ens33
echo "IPADDR=192.168.1.10
NETMASK=255.255.255.0" >>   /etc/sysconfig/network-scripts/ifcfg-ens33
systemctl restart network
cd /etc/yum.repos.d
rm -rf *
echo '[yum]
baseurl=file:///media
enabled=1
gpgcheck=0' > yum.repo
cd
mount /dev/cdrom /media
rpm -e httpd --nodeps
mount /dev/sr0 /media
yum -y install apr apr-devel cyrus-sasl-devel expat-devel libdb-devel openldap-devel apr-util apr-util-devel pcre-devel pcre
tar -zxvf httpd-2.4.25.tar.gz -C /usr/src
cd /usr/src/httpd-2.4.25/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi --enable-sockets
make && make install
ln -s /usr/local/httpd/bin/* /usr/local/bin
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
chmod a+x /etc/init.d/httpd
sed -i '2s/^/#chkconfig:35 85 21\n/g' /etc/init.d/httpd
sed -i '3s/^/#description:apache http server\n/g' /etc/init.d/httpd
chkconfig --add httpd
chkconfig --list
echo "[Unit]
Description=apache http server
after=network.target

[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart=/usr/local/bin/apachectl $OPTION
ExecReload=/bin/kill -HUP $MAINPID
killMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=graphical.target" > /lib/systemd/system/httpd.service
systemctl start httpd
cd
rpm -e mariadb mariadb-server --nodeps
yum -y install ncurses-devel perl perl-devel perl-DBD*
tar -zxvf cmake-2.8.6.tar.gz -C /usr/src
cd /usr/src/cmake-2.8.6
./configure && gmake && gmake install
cd
groupadd mysql
useradd -M -s /sbin/nologin -g mysql mysql
tar -zxvf mysql-5.6.36.tar.gz -C /usr/src
cd /usr/src/mysql-5.6.36
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
make && make install
cd
chown -R mysql:mysql /usr/local/mysql/
rm -f /etc/my.cnf
cp /usr/src/mysql-5.6.36/support-files/my-default.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --group=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
ln -s /usr/local/mysql/bin/* /usr/local/bin
cd /usr/local/bin
cp /usr/src/mysql-5.6.36/support-files/mysql.server /etc/init.d/mysqld
cd
chmod a+x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
/etc/init.d/mysqld start
echo "[Unit]
Description=Mysql server
After=network.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE=5000

[Install]
WantedBy=multi-user.target" > /usr/lib/systemd/system/mysqld.service
systemctl restart mysqld.service
systemctl enable mysqld.service
mysqladmin -u root password 123.com
yum -y install zlib-devel xz-devel libxml2-devel 
tar -zxvf libmcrypt-2.5.8.tar.gz -C /usr/src/
cd /usr/src/libmcrypt-2.5.8/
./configure && make && make install
ln -s /usr/local/lib/libmcrypt.* /usr/lib/
cd
tar -zxvf mhash-0.9.9.9.tar.gz -C /usr/src/
cd /usr/src/mhash-0.9.9.9/
./configure && make && make install
ln -s /usr/local/lib/libmhash* /usr/lib/
cd
tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/src/
cd /usr/src/mcrypt-2.6.8/
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure && make && make install
cd
tar -zxvf php-5.5.38.tar.gz -C /usr/src/
cd /usr/src/php-5.5.38/
./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql  --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php --enable-mbstring --enable-sockets
make && make install
cd
cp /usr/src/php-5.5.38/php.ini-development /usr/local/php/php.ini
sed -i '/;default_charset = "UTF-8"/s/;d/d/g' /usr/local/php/php.ini
sed -i '/;extension=php_mysqli.dll/s/;e/e/g' /usr/local/php/php.ini
sed -i '/short_open_tag = Off/s/Off/On/g' /usr/local/php/php.ini
tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
cp /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/php/lib/php/
sed -i '1933i zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so' /usr/local/php/php.ini
sed -i '1933i zend_loader.enable=1' /usr/local/php/php.ini
sed -i '397i AddType application/x-httpd-php .php' /usr/local/httpd/conf/httpd.conf
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/g' /usr/local/httpd/conf/httpd.conf
sed -i 's/#ServerName www.example.com:80/ServerName 192.168.1.2:80/g' /usr/local/httpd/conf/httpd.conf
systemctl start httpd
cd /usr/local/httpd/htdocs/
mv index.html index.html_back
echo '<?php
$link=mysqli_connect("'"localhost"'","'"root"'","'"123.com"'");                
if($link) echo "恭喜你,数据库连接成功啦!!";                   
?>' > index.php

mysql -uroot -p123.com -e"grant all on *.*to'root'@'localhost'identified by  '123.com';" 
cd
tar -zxvf phpMyAdmin-4.7.2-all-languages.tar.gz -C /usr/src/
cd /usr/src/
cp -r phpMyAdmin-4.7.2-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin
cd /usr/local/httpd/htdocs/phpMyAdmin
cp config.sample.inc.php config.inc.php 
cd
sed -i '17d' /usr/local/httpd/htdocs/phpMyAdmin/config.inc.php
sed -i '17i $cfg['blowfish_secret'] = 'a8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */' /usr/local/httpd/htdocs/phpMyAdmin/config.inc.php

systemctl restart httpd
systemctl restart network

firefox http://127.0.0.1
firefox http://192.168.1.10/phpMyAdmin &

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

数据库从删库到跑路

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

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

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

打赏作者

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

抵扣说明:

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

余额充值