Linux+Apache2.4+MySql5.6+PHP7一键安装脚本(基于Centos)
侧边栏壁纸
  • 累计撰写 114 篇文章
  • 累计收到 21 条评论

Linux+Apache2.4+MySql5.6+PHP7一键安装脚本(基于Centos)

SanLiLin
2019-03-13 / 0 评论 / 458 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2019年03月13日,已超过1468天没有更新,若内容或图片失效,请留言反馈。

现在做网站定制开发前期的准备工作无非就是搭建服务器了,但是有时候手动搭建服务器的时候会出现各种疑难杂症,然后博主整理了一下,搞了个意见LAMP安装脚本,分享一下。

注意:这个安装脚本目前在未安装任何Apache,MySql或PHP的环境下运行完美,服务器中已有数据的话请慎用

脚本代码

#!/bin/bash

updateSystem(){
    echo 'Start to update system softwares...'
    sudo yum -y install sudo
    sudo yum install -y wget
    sudo yum install -y vim
    sudo yum -y check-update
    sudo yum -y update
    echo 'Done.'
}

updateIptables(){
    echo 'Start to update iptables...'
    
    systemctl stop firewalld.service
    systemctl disable firewalld.service
    
    sudo yum install -y iptables-services
    
    iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

    service iptables save
    
    sudo systemctl restart iptables.service
    sudo systemctl enable iptables.service

    echo 'Done.'
}

installApache(){
    echo 'Start to install Apache...'
    sudo yum -y install httpd
    
    sudo yum -y install mod_ssl
    
    sudo yum -y install GraphicsMagick 
    
    sudo sed -i 's/AllowOverride None/AllowOverride All/g' //etc/httpd/conf/httpd.conf
    
    sudo systemctl restart httpd.service
    sudo systemctl enable httpd.service
    echo 'Done.'
}

installPhp(){
    echo 'Start to install PHP...'
    
    rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    yum install php70w* --skip-broken
    
    sudo sed -i 's/memory_limit.*/memory_limit = 128M/g' /etc/php.ini
    sudo sed -i 's/upload_max_filesize.*/upload_max_filesize = 128M/g' /etc/php.ini
    sudo sed -i 's/post_max_size.*/post_max_size = 128M/g' /etc/php.ini
    sudo sed -i 's/max_execution_time.*/max_execution_time = 30000/g' /etc/php.ini
    sudo sed -i 's/max_input_time.*/max_input_time = 30000/g' /etc/php.ini
    sudo sed -i 's/;date.timezone =/date.timezone = Asia\/Shanghai/g' /etc/php.ini
    
    echo 'Done.'
}

installMysql(){
    echo 'Start to install MySql...'

    sudo yum -y install mariadb*
    
    systemctl restart mariadb
    systemctl enable mariadb.service

    echo 'Done.'
}

restartHttpd(){
    echo 'Restart httpd...'

    sudo systemctl restart httpd.service

    echo 'Done.'
}

updateSystem
updateIptables
installApache
installPhp
installMysql
restartHttpd

安装结果

  • Apache安装
  • PHP安装
  • MySQL安装
0

评论 (0)

取消