Linux+Apache+MySQL(可选择安装MariaDB)+PHP (脚本可以选择是否安装+Pureftpd+phpMyAdmin),添加虚拟主机请执行lamp/vhost.sh脚本。脚本中用到的软件包大多最新稳定版本,修复了一些安全性问题(安装之前会执行初始化安全脚本init.sh)。适用于CentOS/RadHat 5/6 。
Github地址:https://github.com/lj2007331/lamp
该脚本不在更新,已经整合到《Oneinstack》;This project already Combined with LNMP, For more information Please visit //linuxeye.com/31.html
LAMP最新源码一键安装脚本问题反馈请加QQ群: 235258658
更新日志:
2013-10-29 更新软件版本
2013-08-17 更新php-5.5.2;防止断网中断安装过程(安装前执行screen -S lamp),如果断网可通过 screen -r lamp 重新连接
2013-08-16 更新ImageMagick-6.8.6-8;一些目录的变更和一些小bug
2013-08-13 添加数据库MariaDB,脚本可以选择安装MySQL还是MariaDB(MariaDB是MySQL分支,参考://linuxeye.com/352.html)
2013-08-09 初始化脚本加入 htop (参考://linuxeye.com/350.html)
2013-08-08 php-5.5内嵌PDO_MYSQL(预编译时加参数--with-pdo-mysql),删除扩展包PDO_MYSQL-1.0.2.tgz (官方说明:http://pecl.php.net/package/PDO_MYSQL);更新phpMyAdmin-4.0.5
2013-08-04 加入防盗链功能(添加虚拟主机可选项)
2013-08-01 更新MySQL-5.6.13
2013-07-29 更新phpMyAdmin-4.0.4.2
2013-07-28 安装sendmail,使服务器能发邮件
2013-07-27 执行lamp安装脚本可选择性的是否安装memcache,安装后默认启动memcached 并开启11211端口
2013-07-25 更新yum时,缺少-y参数,可能导致脚本无法自动下面安装
2013-07-24 发布lamp
lamp安装后占用系统资源截图(top):
使用方法:
cd /root
wget http://mirrors.linuxeye.com/lamp.tar.gz
tar xzf lamp.tar.gz
cd lamp # 如果需要修改目录(安装、数据存储、Nginx日志),请修改options.conf文件
screen -S lamp # 如果网路出现中断,可以执行命令`screen -r lamp`重新连接安装窗口
./install.sh # 请勿sh install.sh或者bash install.sh这样执行
cd ~/lamp # 必须进入lamp目录下执行 ./vhost.sh
脚本中软件版本如下:
cmake-2.8.12.tar.gz
mysql-5.6.14.tar.gz
mariadb-5.5.33a.tar.gz
libiconv-1.14.tar.gz
mcrypt-2.6.8.tar.gz
libmcrypt-2.5.8.tar.gz
mhash-0.9.9.9.tar.gz
php-5.5.5.tar.gz
memcached-1.4.15.tar.gz
memcache-2.2.7.tgz
ImageMagick-6.8.7-3.tar.gz
imagick-3.1.2.tgz
pecl_http-1.7.6.tgz
pcre-8.33.tar.gz
apr-1.4.8.tar.gz
apr-util-1.5.2.tar.gz
httpd-2.4.6.tar.gz
pure-ftpd-1.0.36.tar.gz
phpMyAdmin-4.0.8-all-languages.tar.gz
脚本代码:
#!/bin/bash
# Author: yeho
#.
# Blog: //linuxeye.com
#
# Version: 0.1 21-Aug-2013 lj2007331 AT gmail.com
# Notes: LAMP for CentOS/RadHat 5/6
#
# This script's project home is:
# https://github.com/lj2007331/lamp
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
echo "#######################################################################"
echo "# LAMP for CentOS/RadHat 5/6 #"
echo "# For more information Please visit //linuxeye.com/82.html #"
echo "#######################################################################"
# Check if user is root
[ $(id -u) != "0" ] && echo "Error: You must be root to run this script, Please use root to install lamp" && kill -9 $$
# get ipv4
IP=`ifconfig | grep 'inet addr:' | cut -d: -f2 | grep -v ^10. | grep -v ^192.168 | grep -v ^172. | grep -v ^127. | awk '{print }' | awk '{print;exit}'`
[ ! -n "$IP" ] && IP=`ifconfig | grep 'inet addr:' | cut -d: -f2 | grep -v ^127. | awk '{print }' | awk '{print;exit}'`
#Definition Directory
home_dir=/home/wwwroot
wwwlogs_dir=/home/wwwlogs
mkdir -p $home_dir/default $wwwlogs_dir /root/lamp/{source,conf}
#choice database
while :
do
read -p "Do you want to install MySQL or MariaDB ? ( MySQL / MariaDB ) " choice_DB
choice_db=`echo $choice_DB | tr [A-Z] [a-z]`
if [ "$choice_db" != 'mariadb' ] && [ "$choice_db" != 'mysql' ];then
echo -e "33[31minput error! Please input 'MySQL' or 'MariaDB'33[0m"
else
break
fi
done
#eheck dbrootpwd
while :
do
read -p "Please input the root password of database:" dbrootpwd
(( ${#dbrootpwd} >= 5 )) && break || echo -e "33[31m$choice_DB root password least 5 characters! 33[0m"
done
while :
do
read -p "Do you want to install Memcache? (y/n)" Memcache_yn
if [ "$Memcache_yn" != 'y' ] && [ "$Memcache_yn" != 'n' ];then
echo -e "33[31minput error! Please input 'y' or 'n'33[0m"
else
break
fi
done
while :
do
read -p "Do you want to install Pure-FTPd? (y/n)" FTP_yn
if [ "$FTP_yn" != 'y' ] && [ "$FTP_yn" != 'n' ];then
echo -e "33[31minput error! Please input 'y' or 'n'33[0m"
else
break
fi
done
if [ $FTP_yn == 'y' ];then
while :
do
read -p "Please input the manager password of Pureftpd:" ftpmanagerpwd
(( ${#ftpmanagerpwd} >= 5 )) && break || echo -e "33[31mFtp manager password least 5 characters! 33[0m"
done
fi
while :
do
read -p "Do you want to install phpMyAdmin? (y/n)" phpMyAdmin_yn
if [ "$phpMyAdmin_yn" != 'y' ] && [ "$phpMyAdmin_yn" != 'n' ];then
echo -e "33[31minput error! Please input 'y' or 'n'33[0m"
else
break
fi
done
function Download_src()
{
cd /root/lamp
[ -s init.sh ] && echo 'init.sh found' || wget -c --no-check-certificate https://raw.github.com/lj2007331/lamp/master/init.sh
[ -s vhost.sh ] && echo 'vhost.sh found' || wget -c --no-check-certificate https://raw.github.com/lj2007331/lamp/master/vhost.sh
cd conf
[ -s index.html ] && echo 'index.html found' || wget -c --no-check-certificate https://raw.github.com/lj2007331/lamp/master/conf/index.html
[ -s pure-ftpd.conf ] && echo 'pure-ftpd.conf found' || wget -c --no-check-certificate https://raw.github.com/lj2007331/lamp/master/conf/pure-ftpd.conf
[ -s pureftpd-mysql.conf ] && echo 'pureftpd-mysql.conf found' || wget -c --no-check-certificate https://raw.github.com/lj2007331/lamp/master/conf/pureftpd-mysql.conf
[ -s chinese.php ] && echo 'chinese.php found' || wget -c --no-check-certificate https://raw.github.com/lj2007331/lamp/master/conf/chinese.php
[ -s script.mysql ] && echo 'script.mysql found' || wget -c --no-check-certificate https://raw.github.com/lj2007331/lamp/master/conf/script.mysql
cd /root/lamp/source
[ -s tz.zip ] && echo 'tz.zip found' || wget -c http://www.yahei.net/tz/tz.zip
[ -s cmake-2.8.12.tar.gz ] && echo 'cmake-2.8.12.tar.gz found' || wget -c http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz
[ -s mysql-5.6.14.tar.gz ] && echo 'mysql-5.6.14.tar.gz found' || wget -c http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz
[ -s mariadb-5.5.33a.tar.gz ] && echo 'mariadb-5.5.33a.tar.gz found' || wget -c http://ftp.osuosl.org/pub/mariadb/mariadb-5.5.33a/kvm-tarbake-jaunty-x86/mariadb-5.5.33a.tar.gz
[ -s libiconv-1.14.tar.gz ] && echo 'libiconv-1.14.tar.gz found' || wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[ -s mcrypt-2.6.8.tar.gz ] && echo 'mcrypt-2.6.8.tar.gz found' || wget -c http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
[ -s libmcrypt-2.5.8.tar.gz ] && echo 'libmcrypt-2.5.8.tar.gz found' || wget -c http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
[ -s mhash-0.9.9.9.tar.gz ] && echo 'mhash-0.9.9.9.tar.gz found' || wget -c http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
[ -s php-5.5.5.tar.gz ] && echo 'php-5.5.5.tar.gz found' || wget -c http://kr1.php.net/distributions/php-5.5.5.tar.gz
[ -s memcached-1.4.15.tar.gz ] && echo 'memcached-1.4.15.tar.gz found' || wget -c --no-check-certificate https://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
[ -s memcache-2.2.7.tgz ] && echo 'memcache-2.2.7.tgz found' || wget -c http://pecl.php.net/get/memcache-2.2.7.tgz
[ -s ImageMagick-6.8.7-3.tar.gz ] && echo 'ImageMagick-6.8.7-3.tar.gz found' || wget -c http://www.imagemagick.org/download/ImageMagick-6.8.7-3.tar.gz
[ -s imagick-3.1.2.tgz ] && echo 'imagick-3.1.2.tgz found' || wget -c http://pecl.php.net/get/imagick-3.1.2.tgz
[ -s pecl_http-1.7.6.tgz ] && echo 'pecl_http-1.7.6.tgz found' || wget -c http://pecl.php.net/get/pecl_http-1.7.6.tgz
[ -s pcre-8.33.tar.gz ] && echo 'pcre-8.33.tar.gz found' || wget -c http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-8.33.tar.gz
[ -s apr-1.4.8.tar.gz ] && echo 'apr-1.4.8.tar.gz found' || wget -c http://archive.apache.org/dist/apr/apr-1.4.8.tar.gz
[ -s apr-util-1.5.2.tar.gz ] && echo 'apr-util-1.5.2.tar.gz found' || wget -c http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
[ -s httpd-2.4.6.tar.gz ] && echo 'httpd-2.4.6.tar.gz found' || wget -c http://www.apache.org/dist/httpd/httpd-2.4.6.tar.gz
[ -s pure-ftpd-1.0.36.tar.gz ] && echo 'pure-ftpd-1.0.36.tar.gz found' || wget -c http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz
[ -s ftp_v2.1.tar.gz ] && echo 'ftp_v2.1.tar.gz found' || wget -c http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz
[ -s phpMyAdmin-4.0.8-all-languages.tar.gz ] && echo 'phpMyAdmin-4.0.8-all-languages.tar.gz found' || wget -c http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.0.8/phpMyAdmin-4.0.8-all-languages.tar.gz
# check source packages
for src in `cat /root/lamp/lamp_install.sh | grep found.*wget | awk '{print }' | grep gz`
do
if [ ! -e "/root/lamp/source/$src" ];then
echo -e "33[31m$src no found! 33[0m"
echo -e "33[31mUpdated version of the Package source, Please Contact the author! 33[0m"
kill -9 $$
fi
done
}
function Install_MySQL()
{
cd /root/lamp/source
useradd -M -s /sbin/nologin mysql
mkdir -p $db_data_dir;chown mysql.mysql -R $db_data_dir
tar xzf cmake-2.8.12.tar.gz
cd cmake-2.8.12
./configure
make && make install
cd ..
tar zxf mysql-5.6.14.tar.gz
cd mysql-5.6.14
cmake . -DCMAKE_INSTALL_PREFIX=$db_install_dir
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DMYSQL_DATADIR=$db_data_dir
-DSYSConFDIR=/etc
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
-DWITH_INNObase_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DWITH_BIG_TABLES=1
-DWITH_DEBUG=0
make && make install
if [ -d "$db_install_dir" ];then
echo -e "33[32mMySQL install successfully! 33[0m"
else
echo -e "33[31mMySQL install failed, Please Contact the author! 33[0m"
kill -9 $$
fi
/bin/cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
cd ..
# my.cf
cat > /etc/my.cnf << EOF
[mysqld]
basedir = $db_install_dir
datadir = $db_data_dir
pid-file = $db_data_dir/mysql.pid
character-set-server = utf8
collation-server = utf8_general_ci
user = mysql
port = 3306
default_storage_engine = InnoDB
innodb_file_per_table = 1
server_id = 1
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7
bind-address = 0.0.0.0
# name-resolve
skip-name-resolve
skip-host-cache
#lower_case_table_names = 1
ft_min_word_len = 1
query_cache_size = 64M
query_cache_type = 1
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
# LOG
log_error = $db_data_dir/mysql-error.log
long_query_time = 1
slow_query_log
slow_query_log_file = $db_data_dir/mysql-slow.log
# Oher
#max_connections = 1000
open_files_limit = 65535
[client]
port = 3306
EOF
$db_install_dir/scripts/mysql_install_db --user=mysql --basedir=$db_install_dir --datadir=$db_data_dir
chown mysql.mysql -R $db_data_dir
/sbin/service mysqld start
export PATH=$PATH:$db_install_dir/bin
echo "export PATH=$PATH:$db_install_dir/bin" >> /etc/profile
source /etc/profile
$db_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by "$dbrootpwd" with grant option;"
$db_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by "$dbrootpwd" with grant option;"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
/sbin/service mysqld restart
}
function Install_MariaDB()
{
cd /root/lamp/source
useradd -M -s /sbin/nologin mysql
mkdir -p $db_data_dir;chown mysql.mysql -R $db_data_dir
tar xzf cmake-2.8.12.tar.gz
cd cmake-2.8.12
./configure
make && make install
cd ..
tar zxf mariadb-5.5.33a.tar.gz
cd mariadb-5.5.33a
cmake . -DCMAKE_INSTALL_PREFIX=$db_install_dir
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DMYSQL_DATADIR=$db_data_dir
-DSYSConFDIR=/etc
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
-DWITH_ARIA_STORAGE_ENGINE=1
-DWITH_XTRADB_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_INNObase_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DWITH_BIG_TABLES=1
-DWITH_DEBUG=0
make && make install
if [ -d "$db_install_dir" ];then
echo -e "33[32mMariaDB install successfully! 33[0m"
else
echo -e "33[31mMariaDB install failed, Please Contact the author! 33[0m"
kill -9 $$
fi
/bin/cp support-files/my-small.cnf /etc/my.cnf
/bin/cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
cd ..
# my.cf
cat > /etc/my.cnf << EOF
[mysqld]
basedir = $db_install_dir
datadir = $db_data_dir
pid-file = $db_data_dir/mariadb.pid
character-set-server = utf8
collation-server = utf8_general_ci
user = mysql
port = 3306
default_storage_engine = InnoDB
innodb_file_per_table = 1
server_id = 1
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7
bind-address = 0.0.0.0
# name-resolve
skip-name-resolve
skip-host-cache
#lower_case_table_names = 1
ft_min_word_len = 1
query_cache_size = 64M
query_cache_type = 1
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
# LOG
log_error = $db_data_dir/mariadb-error.log
long_query_time = 1
slow_query_log
slow_query_log_file = $db_data_dir/mariadb-slow.log
# Oher
#max_connections = 1000
open_files_limit = 65535
[client]
port = 3306
EOF
$db_install_dir/scripts/mysql_install_db --user=mysql --basedir=$db_install_dir --datadir=$db_data_dir
chown mysql.mysql -R $db_data_dir
/sbin/service mysqld start
export PATH=$PATH:$db_install_dir/bin
echo "export PATH=$PATH:$db_install_dir/bin" >> /etc/profile
source /etc/profile
$db_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by "$dbrootpwd" with grant option;"
$db_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by "$dbrootpwd" with grant option;"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
/sbin/service mysqld restart
}
function Install_Apache()
{
useradd -M -s /sbin/nologin www
cd /root/lamp/source
tar xzf pcre-8.33.tar.gz
cd pcre-8.33
./configure
make && make install
cd ../
tar xzf httpd-2.4.6.tar.gz
tar xzf apr-1.4.8.tar.gz
tar xzf apr-util-1.5.2.tar.gz
cd httpd-2.4.6
/bin/cp -R ../apr-1.4.8 ./srclib/apr
/bin/cp -R ../apr-util-1.5.2 ./srclib/apr-util
./configure --prefix=/usr/local/apache --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=prefork --disable-userdir --disable-cgid --disable-cgi
make && make install
/bin/cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
chkconfig --add httpd
chkconfig httpd on
cd ..
#logrotate apache log
cat > /etc/logrotate.d/apache << EOF
$wwwlogs_dir/*.log {
daily
rotate 5
missingok
dateext
compress
notifempty
sharedscripts
postrotate
[ -f /usr/local/apache/logs/httpd.pid ] && kill -USR1 `cat /usr/local/apache/logs/httpd.pid`
endscript
}
EOF
service httpd start
}
function Apache_conf()
{
sed -i 's/^User daemon/User www/' /usr/local/apache/conf/httpd.conf
sed -i 's/^Group daemon/Group www/' /usr/local/apache/conf/httpd.conf
sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' /usr/local/apache/conf/httpd.conf
sed -i "s@AddType(.*)Z@AddType1Zn AddType application/x-httpd-php .php .phtmln AddType application/x-httpd-php-source .phps@" /usr/local/apache/conf/httpd.conf
sed -i 's@^#LoadModule(.*)mod_deflate.so@LoadModule1mod_deflate.so@' /usr/local/apache/conf/httpd.conf
sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' /usr/local/apache/conf/httpd.conf
sed -i "s@^documentRoot.*@documentRoot "$home_dir/default"@" /usr/local/apache/conf/httpd.conf
sed -i "s@^@ @" /usr/local/apache/conf/httpd.conf
mkdir /usr/local/apache/conf/vhost
cat > /usr/local/apache/conf/vhost/admin.conf << EOF
ServerAdmin admin@linuxeye.com
documentRoot "$home_dir/default"
ServerName $IP
ErrorLog "$wwwlogs_dir/admin-error.log"
CustomLog "$wwwlogs_dir/admin-access.log" common
SetOutputFilter DEFLATE
Options FollowSymlinks
Require all granted
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
EOF
cat >> /usr/local/apache/conf/httpd.conf < ServerTokens ProductOnlyServerSignature OffAddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascriptDeflateCompressionLevel 6SetOutputFilter DEFLATEInclude conf/vhost/*.confEOF}function Install_PHP(){cd /root/lamp/sourcetar xzf libiconv-1.14.tar.gzcd libiconv-1.14./configure --prefix=/usr/localmake && make installcd ../tar xzf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8./configuremake && make install/sbin/ldconfigcd libltdl/./configure --enable-ltdl-installmake && make installcd ../../tar xzf mhash-0.9.9.9.tar.gzcd mhash-0.9.9.9./configuremake && make installcd ../tar xzf ImageMagick-6.8.7-3.tar.gzcd ImageMagick-6.8.7-3./configuremake && make installcd ../# linked librarycat >> /etc/ld.so.conf.d/local.conf < /usr/local/libEOFcat >> /etc/ld.so.conf.d/mysql.conf < $db_install_dir/libEOF/sbin/ldconfigln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-configln -s $db_install_dir/include/* /usr/local/include/ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagickif [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; thenln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1cp -frp /usr/lib64/libldap* /usr/libelseln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1fitar xzf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8/sbin/ldconfig./configuremake && make installcd ../tar xzf php-5.5.5.tar.gzcd php-5.5.5./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs--with-config-file-path=/usr/local/php/etc --enable-opcache --with-mysql=$db_install_dir--with-mysqli=$db_install_dir/bin/mysql_config --with-pdo-mysql --disable-fileinfo--with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif--enable-sysvsem --enable-inline-optimization --with-curl --with-kerberos --enable-mbregex--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-xsl --with-openssl--with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc--enable-ftp --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debugmake ZEND_EXTRA_LIBS='-liconv'make installif [ -d "/usr/local/php" ];thenecho -e "33[32mPHP install successfully! 33[0m"elseecho -e "33[31mPHP install failed, Please Contact the author! 33[0m"kill -9 $$fi#wget -c http://pear.php.net/go-pear.phar#/usr/local/php/bin/php go-pear.phar/bin/cp php.ini-production /usr/local/php/etc/php.inicd ..tar xzf imagick-3.1.2.tgzcd imagick-3.1.2export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make installcd ../# Support HTTP request curlstar xzf pecl_http-1.7.6.tgzcd pecl_http-1.7.6/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make installcd ../# Modify php.inised -i "s@extension_dir = "ext"@extension_dir = "ext"nextension_dir = "/usr/local/php/lib/php/extensions/`ls /usr/local/php/lib/php/extensions/`"nextension = "imagick.so"nextension = "http.so"@" /usr/local/php/etc/php.inised -i 's@^output_buffering =@output_buffering = Onnoutput_buffering =@' /usr/local/php/etc/php.inised -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' /usr/local/php/etc/php.inised -i 's@^short_open_tag = Off@short_open_tag = On@' /usr/local/php/etc/php.inised -i 's@^expose_php = On@expose_php = Off@' /usr/local/php/etc/php.inised -i 's@^request_order.*@request_order = "CGP"@' /usr/local/php/etc/php.inised -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' /usr/local/php/etc/php.inised -i 's@^post_max_size.*@post_max_size = 50M@' /usr/local/php/etc/php.inised -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' /usr/local/php/etc/php.inised -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' /usr/local/php/etc/php.inised -i 's@^max_execution_time.*@max_execution_time = 300@' /usr/local/php/etc/php.inised -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket@' /usr/local/php/etc/php.inised -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' /usr/local/php/etc/php.inised -i 's@^pdo_mysql.default_socket.*@pdo_mysql.default_socket = /tmp/mysql.sock@' /usr/local/php/etc/php.inised -i 's@#sendmail_path.*@#sendmail_path = /usr/sbin/sendmail -t@' /usr/local/php/etc/php.inised -i 's@^[opcache]@[opcache]nzend_extension=opcache.so@' /usr/local/php/etc/php.inised -i 's@^;opcache.enable=.*@opcache.enable=1@' /usr/local/php/etc/php.inised -i 's@^;opcache.memory_consumption.*@opcache.memory_consumption=128@' /usr/local/php/etc/php.inised -i 's@^;opcache.interned_strings_buffer.*@opcache.interned_strings_buffer=8@' /usr/local/php/etc/php.inised -i 's@^;opcache.max_accelerated_files.*@opcache.max_accelerated_files=4000@' /usr/local/php/etc/php.inised -i 's@^;opcache.revalidate_freq.*@opcache.revalidate_freq=60@' /usr/local/php/etc/php.inised -i 's@^;opcache.fast_shutdown.*@opcache.fast_shutdown=1@' /usr/local/php/etc/php.inised -i 's@^;opcache.enable_cli.*@opcache.enable_cli=1@' /usr/local/php/etc/php.ini}function Install_Memcache(){cd /root/lamp/sourcetar xzf memcache-2.2.7.tgzcd memcache-2.2.7/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make installsed -i 's@^extension_dir(.*)@extension_dir1nextension = "memcache.so"@' /usr/local/php/etc/php.inicd ../tar xzf memcached-1.4.15.tar.gzcd memcached-1.4.15./configure --prefix=/usr/local/memcachedmake && make installln -s /usr/local/memcached/bin/memcached /usr/bin/memcached/bin/cp scripts/memcached.sysv /etc/init.d/memcachedsed -i 's@^USER=.*@USER=root@' /etc/init.d/memcachedsed -i 's@chown@#chown@' /etc/init.d/memcachedsed -i 's@/var/run/memcached/memcached.pid@/var/run/memcached.pid@' /etc/init.d/memcachedsed -i 's@^prog=.*@prog="/usr/local/memcached/bin/memcached"@' /etc/init.d/memcachedchmod +x /etc/init.d/memcachedchkconfig --add memcachedchkconfig memcached onservice memcached startcd ..}function Install_Pureftp(){cd /root/lamp/sourcetar xzf pure-ftpd-1.0.36.tar.gzcd pure-ftpd-1.0.36./configure --prefix=/usr/local/pureftpd CFLAGS=-O2 --with-mysql=$db_install_dir --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=englishmake && make installcp configuration-file/pure-config.pl /usr/local/pureftpd/sbinchmod +x /usr/local/pureftpd/sbin/pure-config.plcp contrib/redhat.init /etc/init.d/pureftpdsed -i 's@fullpath=.*@fullpath=/usr/local/pureftpd/sbin/$prog@' /etc/init.d/pureftpdsed -i 's@pureftpwho=.*@pureftpwho=/usr/local/pureftpd/sbin/pure-ftpwho@' /etc/init.d/pureftpdsed -i 's@/etc/pure-ftpd.conf@/usr/local/pureftpd/pure-ftpd.conf@' /etc/init.d/pureftpdchmod +x /etc/init.d/pureftpdchkconfig --add pureftpdchkconfig pureftpd oncd /root/lamp/conf/bin/cp pure-ftpd.conf /usr/local/pureftpd//bin/cp pureftpd-mysql.conf /usr/local/pureftpd/mysqlftppwd=`cat /dev/urandom | head -1 | md5sum | head -c 8`sed -i 's/tmppasswd/'$mysqlftppwd'/g' /usr/local/pureftpd/pureftpd-mysql.confsed -i 's/mysqlftppwd/'$mysqlftppwd'/g' script.mysqlsed -i 's/ftpmanagerpwd/'$ftpmanagerpwd'/g' script.mysql$db_install_dir/bin/mysql -uroot -p$dbrootpwd < script.mysqlservice pureftpd starttar xzf /root/lamp/source/ftp_v2.1.tar.gzsed -i 's/tmppasswd/'$mysqlftppwd'/' ftp/config.phpsed -i "s/myipaddress.com/`echo $IP`/" ftp/config.phpsed -i 's@$DEFUserID.*;@$DEFUserID = "501";@' ftp/config.phpsed -i 's@$DEFGroupID.*;@$DEFGroupID = "501";@' ftp/config.phpsed -i 's@iso-8859-1@UTF-8@' ftp/language/english.php/bin/cp /root/lamp/conf/chinese.php ftp/language/sed -i 's@$LANG.*;@$LANG = "chinese";@' ftp/config.phprm -rf ftp/install.phpmv ftp $home_dir/default}function Install_phpMyAdmin(){cd $home_dir/defaulttar xzf /root/lamp/source/phpMyAdmin-4.0.8-all-languages.tar.gzmv phpMyAdmin-4.0.8-all-languages phpMyAdmin}function TEST(){echo 'phpinfo()?>' > $home_dir/default/phpinfo.phpcp /root/lamp/conf/index.html $home_dir/defaultunzip -q /root/lamp/source/tz.zip -d $home_dir/defaultchown -R www.www $home_dir/defaultservice httpd restart}function Iptables(){cat > /etc/sysconfig/iptables << EOF# Firewall configuration written by system-config-securitylevel# Manual customization of this file is not recommended.*filter:INPUT DROP [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]:syn-flood - [0:0]-A INPUT -i lo -j ACCEPT-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT-A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT-A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood-A INPUT -j REJECT --reject-with icmp-host-prohibited-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN-A syn-flood -j REJECT --reject-with icmp-port-unreachableCOMMITEOFservice iptables restart}Download_src 2>&1 | tee -a /root/lamp/lamp_install.logchmod +x /root/lamp/{init,vhost}.shsed -i "s@/home/wwwroot@$home_dir@g" /root/lamp/vhost.shsed -i "s@/home/wwwlogs@$wwwlogs_dir@g" /root/lamp/vhost.sh/root/lamp/init.sh 2>&1 | tee -a /root/lamp/lamp_install.logif [ $choice_db == 'mysql' ];thendb_install_dir=/usr/local/mysqldb_data_dir=/data/mysqlInstall_MySQL 2>&1 | tee -a /root/lamp/lamp_install.logfiif [ $choice_db == 'mariadb' ];thendb_install_dir=/usr/local/mariadbdb_data_dir=/data/mariadbInstall_MariaDB 2>&1 | tee -a /root/lamp/lamp_install.logfiInstall_Apache 2>&1 | tee -a /root/lamp/lamp_install.logInstall_PHP 2>&1 | tee -a /root/lamp/lamp_install.logif [ $Memcache_yn == 'y' ];thenInstall_Memcache 2>&1 | tee -a /root/lamp/lamp_install.logfiif [ $FTP_yn == 'y' ];thenInstall_Pureftp 2>&1 | tee -a /root/lamp/lamp_install.logIptables 2>&1 | tee -a /root/lamp/lamp_install.logfiif [ $phpMyAdmin_yn == 'y' ];thenInstall_phpMyAdmin 2>&1 | tee -a /root/lamp/lamp_install.logfiApache_conf 2>&1 | tee -a /root/lamp/lamp_install.logTEST 2>&1 | tee -a /root/lamp/lamp_install.logecho "################Congratulations####################"echo -e "33[32mPlease restart the server and see if the services start up fine.33[0m"echo ''echo "The path of some dirs:"echo -e "`printf "%-32s" "Apache dir:"`33[32m/usr/local/apache33[0m"echo -e "`printf "%-32s" "$choice_DB dir:"`33[32m$db_install_dir33[0m"echo -e "`printf "%-32s" "PHP dir:"`33[32m/usr/local/php33[0m"echo -e "`printf "%-32s" "$choice_DB User:"`33[32mroot33[0m"echo -e "`printf "%-32s" "$choice_DB Password:"`33[32m${dbrootpwd}33[0m"echo -e "`printf "%-32s" "Manager url:"`33[32mhttp://$IP/33[0m"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)