#!/bin/bash
#在docker centos:6安装lamp脚本
#renphp 20160706
#一安装更改yum源
yum install -y wget
yum install -y epel-release.noarch
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum clean all
yum makecache
yum update -y
#二安装httpd
yum install httpd -y
sed -i 's/#ServerName www.example.com:80/ServerName www.example.com:80/' /etc/httpd/conf/httpd.conf
chkconfig --level 3 httpd on
/etc/init.d/httpd start
#三安装mysql
yum install mysql mysql-server -y
chkconfig --level 3 mysqld on
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
/etc/init.d/mysqld start
/usr/bin/mysqladmin -u root password 'root'
mysql -uroot -proot -e "delete from mysql.user where user='' or password='';"
mysql -uroot -proot -e "drop database test;"
history -c
/etc/init.d/mysqld restart
#四安装php
yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath mhash-devel libmcrypt
#五配置LAMP
sed -i "s/erverTokens OS/erverTokens Prod/g" /etc/httpd/conf/httpd.conf
sed -i "s/ServerSignature On/ServerSignature Off/g" /etc/httpd/conf/httpd.conf
sed -i "s/Options Indexes FollowSymLinks/Options Includes ExecCGI FollowSymLinks/g" /etc/httpd/conf/httpd.conf
sed -i "s/DirectoryIndex index.html index.html.var/DirectoryIndex index.php index.html index.htm/g" /etc/httpd/conf/httpd.conf
sed -i "s/KeepAlive Off/KeepAlive On/g" /etc/httpd/conf/httpd.conf
sed -i "s/MaxKeepAliveRequests 100/MaxKeepAliveRequests 1000/g" /etc/httpd/conf/httpd.conf
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html
sed -i "s/;date.timezone =/date.timezone = PRC/" /etc/php.ini
sed -i "s/expose_php = On/expose_php = Off/" /etc/php.ini
sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php.ini
sed -i "s/disable_functions =/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname/" /etc/php.ini
echo -e "<?php\nphpinfo();" > /var/www/html/index.php
/etc/init.d/mysqld restart
/etc/init.d/httpd restart
#原文链接:http://my.oschina.net/phpecshop/blog/701728