LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > 脚本编程 >

LAMP源码安装脚本

时间:2015-06-08 15:10来源:http://blog.linuxeye.com 编辑:admin 点击:
脚本中开源软件版本: httpd-2.2.22.tar.gzcmake-2.8.4.tar.gzmysql-5.5.10.tar.gzlibiconv-1.13.1.tar.gzlibmcrypt-2.5.8.tar.gzmhash-0.9.9.9.tar.gzmcrypt-2.6.8.tar.gzphp-5.3.10.tar.gzmemcache-2.2.5.tgzeaccelerator-0.9.6.1.tar.bz2PDO_MYSQ

Linux+Apache+MySQL可选择安装MariaDB)+PHP (脚本可以选择是否安装+Pureftpd+User manager for PureFTPd+phpMyAdmin),添加虚拟主机请执行lamp/vhost.sh脚本。脚本中用到的软件包大多最新稳定版本,修复了一些安全性问题(安装之前会执行初始化安全脚本init.sh)。适用于CentOS/RadHat 5/6 。

Github地址:https://github.com/lj2007331/lamp

该脚本不在更新,已经整合到《lnmp一键安装包;This project already Combined with LNMP, For more information Please visit http://blog.linuxeye.com/31.html

LAMP最新源码一键安装脚本问题反馈请加QQ群: 235258658
 

使用方法:
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这样执行
脚本内容:
#!/bin/bash
#by LinuxEye
#BLOG: http://blog.linuxeye.com
#安装依赖包
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel  openldap-clients openldap-servers libxslt-devel libevent-devel ntp  libtool-ltdl bison libtool vim-enhanced gd gd-devel
if [ -e "/root/lamp" ];then
echo -e "\e[0;34m start install\e[0m"
cd /root/lamp/apache
else
echo -e "\e[1;31mPlease send lamp directory moved to /root\e[0m"
exit 1
fi

#安装apache
useradd -M -s /sbin/nologin www
tar xzf httpd-2.2.22.tar.gz
cd httpd-2.2.22
./configure --prefix=/usr/local/apache --enable-so --enable-ssl \
--enable-rewrite --enable-headers --enable-deflate --with-mpm=worker
make && make install
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 ..

#安装mysql-5.5.10
cd /root/lamp/mysql
useradd -M -s /sbin/nologin mysql
mkdir -p /data/mysql;chown mysql.mysql -R /data/mysql
tar xzf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure
make &&  make install
cd ..
tar zxf mysql-5.5.10.tar.gz
cd mysql-5.5.10
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DMYSQL_DATADIR=/data/mysql  \
-DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DCMAKE_THREAD_PREFER_PTHREAD=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DWITH_DEBUG=0
make && make install

cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
#修改配置文件
sed -i '38a ##############' /etc/my.cnf
sed -i '39a skip-name-resolve' /etc/my.cnf
sed -i '40a basedir=/usr/local/mysql' /etc/my.cnf
sed -i '41a datadir=/data/mysql' /etc/my.cnf
sed -i '42a user=mysql' /etc/my.cnf
sed -i '43a #lower_case_table_names = 1' /etc/my.cnf
sed -i '44a max_connections=1000' /etc/my.cnf
sed -i '45a ft_min_word_len=1' /etc/my.cnf
sed -i '46a expire_logs_days = 7' /etc/my.cnf
sed -i '47a query_cache_size=64M' /etc/my.cnf
sed -i '48a query_cache_type=1' /etc/my.cnf
sed -i '49a ##############' /etc/my.cnf

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql

chown mysql.mysql -R /data/mysql
/sbin/service mysqld start
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile

/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'%' identified by 'admin' with grant option;"
/usr/local/mysql/bin/mysql -e "flush privileges;"
/usr/local/mysql/bin/mysql -e "delete from mysql.user where password='';"

/sbin/service mysqld restart
#安装php
cd /root/lamp/php
tar xzf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local
make && make install

cd ../
tar xzf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
cd ../../

tar xzf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install
cd ../

if [ -e "/lib64" ];then
ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib64/libmysqlclient.so.18
else
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib/libmysqlclient.so.18
fi

tar xzf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
/sbin/ldconfig
./configure
make && make install
cd ../
tar xzf php-5.3.10.tar.gz
cd php-5.3.10
./configure  --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --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-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-ftp --enable-zip --enable-soap --disable-debug

make ZEND_EXTRA_LIBS='-liconv' && make install
cp php.ini-production /usr/local/php/lib/php.ini
cd ../

tar xzf memcache-2.2.5.tgz
cd memcache-2.2.5
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../

tar xjf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../

tar xzf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make && make install
cd ../

tar xzf ImageMagick-6.6.7-10.tar.gz
cd ImageMagick-6.6.7-10
./configure
make && make install
cd ../

tar xzf imagick-2.3.0.tgz
cd imagick-2.3.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../

#修改php.ini
mkdir /tmp/eaccelerator
/bin/chown -R www.www /tmp/eaccelerator/
sed -i 's@expose_php = On@expose_php = Off@g' /usr/local/php/lib/php.ini   #隐藏php版本信息
sed -i '808a extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626/"' /usr/local/php/lib/php.ini
sed -i '809a extension = "memcache.so"' /usr/local/php/lib/php.ini
sed -i '810a extension = "pdo_mysql.so"' /usr/local/php/lib/php.ini
sed -i '811a extension = "imagick.so"' /usr/local/php/lib/php.ini
sed -i '134a output_buffering = On' /usr/local/php/lib/php.ini
sed -i '847a cgi.fix_pathinfo=0' /usr/local/php/lib/php.ini
sed -i 's@;date.timezone =@date.timezone = Asia/Shanghai@g' /usr/local/php/lib/php.ini
echo '[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="0"
eaccelerator.compress_level="9"
eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"' >> /usr/local/php/lib/php.ini

#修改apache配置文件
if [ "$(hostname -i)" == "127.0.0.1" ];then
echo "OK"
else
sed -i "s/127.0.0.1.*$/127.0.0.1       `hostname`  localhost.localdomain localhost/g" /etc/hosts
fi

sed -i 's/User daemon/User www/g' /usr/local/apache/conf/httpd.conf
sed -i 's/Group daemon/User www/g' /usr/local/apache/conf/httpd.conf
sed -i 's/#ServerName www.example.com:80/ServerName 127.0.0.1:80/g' /usr/local/apache/conf/httpd.conf
sed -i '288a AddType application/x-httpd-php .php .phtml' /usr/local/apache/conf/httpd.conf
sed -i '289a AddType application/x-httpd-php-source .phps' /usr/local/apache/conf/httpd.conf
sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@g' /usr/local/apache/conf/httpd.conf
cat >> /usr/local/apache/conf/httpd.conf <<EOF #隐藏apache版本信息
ServerTokens ProductOnly
ServerSignature Off
EOF

service httpd start

转载请保留固定链接: https://linuxeye.com/program/313.html

------分隔线----------------------------
标签:mysqlphplampapachelinux脚本
栏目列表
推荐内容