shell-网上lnmp一键安装讲解
Posted Ame启风
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell-网上lnmp一键安装讲解相关的知识,希望对你有一定的参考价值。
shell-网上lnmp一键安装讲解
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin #设置系统环境变量本文出处:www.ksharpdabu.info
export PATH #
# Check if user is root
if [ $(id -u) != "0" ]; then #通过判断当前用户的id来判断是否为root用户
echo "Error: You must be root to run this script, please use root to install lnmp" #不是则提示:该脚本必须以root身份运行,请用root身份安装lnmp
exit 1 #失败则退出
fi
clear
echo "=========================================================================" #下面几行就是输出安装脚本的相关信息和作者介绍本文出处:www.ksharpdabu.info
echo "LNMP V0.9 for CentOS/RadHat Linux VPS Written by Licess"
echo "========================================================================="
echo "A tool to auto-compile & install nginx+mysql+php on Linux "
echo ""
echo "For more information please visit http://www.lnmp.org/"
echo "========================================================================="
cur_dir=$(pwd) #将当前目录赋值给cur_dir变量
if [ "$1" != "--help" ]; then #判断你输入的参数是否是--help,不是则继续执行
#set main domain name #设置域名的相关信息
domain="www.lnmp.org" #将www.lnmp.org赋值给domain这个变量
echo "Please input domain:" #提示内容:请输入域名
read -p "(Default domain: www.lnmp.org):" domain #等待读取用户输入的域名,如果直接回车,则默认域名为www.lnmp.org本文出处:www.ksharpdabu.info
if [ "$domain" = "" ]; then #判断用户是否输入域名,如果为空,则默认域名为www.lnmp.org
domain="www.lnmp.org"
fi
echo "==========================="
echo domain="$domain" #显示用户输入的域名本文出处:www.ksharpdabu.info
echo "==========================="
#set mysql root password #设置mysql的root的密码
echo "==========================="
mysqlrootpwd="root" #将root赋值给mysqlrootpwd
echo "Please input the root password of mysql:" #提示:设置mysql的root密码为
read -p "(Default password: root):" mysqlrootpwd #读取用户输入的mysql的root密码,输入则赋值给mysqlrootpwd这个变量,直接回车则默认密码是root
if [ "$mysqlrootpwd" = "" ]; then #判断用户是否输入,如果输入为空,则默认密码为root本文出处:www.ksharpdabu.info
mysqlrootpwd="root"
fi
echo "==========================="
echo mysqlrootpwd="$mysqlrootpwd" #显示用户设置的mysql的root密码
echo "==========================="
#do you want to install the InnoDB Storage Engine? #问用户是否想安装innodb引擎
echo "==========================="
installinnodb="n" #将1赋值给installinnodb这个变量
echo "Do you want to install the InnoDB Storage Engine?" #提示你是否想安装innodb这个引擎
read -p "(Default no,if you want please input: y ,if not please press the enter button):" installinnodb #读取用户的输入,直接回车则默认是不安装
case "$installinnodb" in #这里判断用户输入的内容,是y|Y|Yes|YES|yes|yES|yEs|YeS|yeS任意一个,就安装innodb引擎本文出处:www.ksharpdabu.info
y|Y|Yes|YES|yes|yES|yEs|YeS|yeS)
echo "You will install the InnoDB Storage Engine" #提示:你将会安装innodb引擎
installinnodb="y" #将y赋值给installdb这个变量
;;
n|N|No|NO|no|nO) #若用户输入的是n|N|No|NO|no|nO任意一种,则不安装引擎
echo "You will NOT install the InnoDB Storage Engine!" #提示:将不会为你安装innodb引擎本文出处:www.ksharpdabu.info
installinnodb="n" #将n赋值给installinnodb
;;
*)
echo "INPUT error,The InnoDB Storage Engine will NOT install!" #如果用户输入的既不是y|Y|Yes|YES|yes|yES|yEs|YeS|yeS和n|N|No|NO|no|nO中的一种,则提示错误,并且不会安装引擎
installinnodb="n" #将n赋值给installinnodb
esac
get_char() #这一段的代码其实的功能就是让用户输入任意键以继续执行脚本,是常用的代码段
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start..."
char=`get_char`
#Set timezone #设置系统的时区
rm -rf /etc/localtime #强制删除/etc/localtime文件夹和里面的文件
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime #做个软链接,提示就是将时区设置为上海的本文出处:www.ksharpdabu.info
yum install -y ntp #yum安装ntp
ntpdate -u pool.ntp.org #使用ntp这个工具通过网络与pool.ntp.org 同步时间
date #显示日期
rpm -qa|grep httpd #显示系统中所有已经安装的rpm包中是否有httpd,其实就是apache本文出处:www.ksharpdabu.info
rpm -e httpd #删除httpd包,也即是删除已经安装的apache
rpm -qa|grep mysql #显示系统中所有已经安装的rpm包中是否有mysql
rpm -e mysql #删除mysql
rpm -qa|grep php #显示系统中所有已经安装的rpm包中是否有php
rpm -e php #删除系统中已经安装的php
yum -y remove httpd* #yum卸载httpd相关组件
yum -y remove php* #yum卸载php
yum -y remove mysql-server mysql #yum卸载mysql相关服务
yum -y remove php-mysql #yum卸载php-mysql
yum -y install yum-fastestmirror #yum安装yum自动匹配快速源插件
yum -y remove httpd #删除httpd
#yum -y update
#Disable SeLinux #这段就是关闭selinux
if [ -s /etc/selinux/config ]; then #判断/etc/selinux/config文件是否存在,且大小大于0本文出处:www.ksharpdabu.info
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/selinux/config #存在则将selinux关闭
fi
cp /etc/yum.conf /etc/yum.conf.lnmp #备份/etc/yum.conf为/etc/yum.conf.lnmp
sed -i ‘s:exclude=.*:exclude=:g‘ /etc/yum.conf #设置为所有软件都升级
for packages in patch make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap; #安装lnmp相关的库文件和依赖包
do yum -y install $packages; done #这里就是个循环的操作啦
mv -f /etc/yum.conf.lnmp /etc/yum.conf #将/etc/yum.conf.lnmp重命名为/etc/yum.conf
echo "============================check files==================================" #这段用来检测相应的安装文件文件是否存在本文出处:www.ksharpdabu.info
if [ -s php-5.2.17.tar.gz ]; then #检测php-5.2.17.tar.gz是否存在
echo "php-5.2.17.tar.gz [found]" #检测到存在,则在屏幕上输出php-5.2.17.tar.gz找到
else
echo "Error: php-5.2.17.tar.gz not found!!!download now......" #没找到,则报错:php-5.2.17.tar.gz没有找到,脚本自动去网上下载php-5.2.17.tar.gz
wget -c http://soft.vpser.net/web/php/php-5.2.17.tar.gz #用wget工具从网上下载php-5.2.17.tar.gz(其实就是军哥的网站啦,好奇每个月军哥要耗费多少流量)
fi
if [ -s php-5.2.17-fpm-0.5.14.diff.gz ]; then #检测php-5.2.17-fpm-0.5.14.diff.gz是否存在
echo "php-5.2.17-fpm-0.5.14.diff.gz [found]" #检测到存在,则在屏幕上输出php-5.2.17-fpm-0.5.14.diff.gz找到
else
echo "Error: php-5.2.17-fpm-0.5.14.diff.gz not found!!!download now......" #没找到,则报错:php-5.2.17-fpm-0.5.14.diff.gz没有找到,脚本自动去网上下载php-5.2.17-fpm-0.5.14.diff.gz
wget -c http://soft.vpser.net/web/phpfpm/php-5.2.17-fpm-0.5.14.diff.gz #用wget工具从网上下载php-5.2.17-fpm-0.5.14.diff.gz
fi
if [ -s memcache-3.0.6.tgz ]; then #检测memcache-3.0.6.tgz是否存在
echo "memcache-3.0.6.tgz [found]" #检测到存在,则在屏幕上输出memcache-3.0.6.tgz找到
else
echo "Error: memcache-3.0.6.tgz not found!!!download now......" #没找到,则报错:memcache-3.0.6.tgz没有找到,脚本自动去网上下载memcache-3.0.6.tgz
wget -c http://soft.vpser.net/web/memcache/memcache-3.0.6.tgz #用wget工具从网上下载memcache-3.0.6.tgz
fi
if [ -s pcre-8.12.tar.gz ]; then #检测pcre-8.12.tar.gz是否存在
echo "pcre-8.12.tar.gz [found]" #检测到存在,则在屏幕上输出pcre-8.12.tar.gz找到
else
echo "Error: pcre-8.12.tar.gz not found!!!download now......" #没找到,则报错:pcre-8.12.tar.gz没有找到,脚本自动去网上下载pcre-8.12.tar.gz
wget -c http://soft.vpser.net/web/pcre/pcre-8.12.tar.gz #用wget工具从网上下载pcre-8.12.tar.gz本文出处:www.ksharpdabu.info
fi
if [ -s nginx-1.0.15.tar.gz ]; then #检测nginx-1.0.15.tar.gz是否存在
echo "nginx-1.0.15.tar.gz [found]" #检测到存在,则在屏幕上输出nginx-1.0.15.tar.gz找到
else
echo "Error: nginx-1.0.15.tar.gz not found!!!download now......" #没找到,则报错:nginx-1.0.15.tar.gz没有找到,脚本自动去网上下载nginx-1.0.15.tar.gz
wget -c http://soft.vpser.net/web/nginx/nginx-1.0.15.tar.gz #用wget工具从网上下载nginx-1.0.15.tar.gz
fi
if [ -s mysql-5.1.60.tar.gz ]; then #检测mysql-5.1.60.tar.gz是否存在
echo "mysql-5.1.60.tar.gz [found]" #检测到存在,则在屏幕上输出mysql-5.1.60.tar.gz找到
else
echo "Error: mysql-5.1.60.tar.gz not found!!!download now......" #没找到,则报错:mysql-5.1.60.tar.gz没有找到,脚本自动去网上下载mysql-5.1.60.tar.gz
wget -c http://soft.vpser.net/datebase/mysql/mysql-5.1.60.tar.gz #用wget工具从网上下载mysql-5.1.60.tar.gz
fi
if [ -s libiconv-1.14.tar.gz ]; then #检测libiconv-1.14.tar.gz是否存在
echo "libiconv-1.14.tar.gz [found]" #检测到存在,则在屏幕上输出libiconv-1.14.tar.gz找到本文出处:www.ksharpdabu.info
else
echo "Error: libiconv-1.14.tar.gz not found!!!download now......" #没找到,则报错:libiconv-1.14.tar.gz没有找到,脚本自动去网上下载libiconv-1.14.tar.gz
wget -c http://soft.vpser.net/web/libiconv/libiconv-1.14.tar.gz #用wget工具从网上下载libiconv-1.14.tar.gz
fi
if [ -s libmcrypt-2.5.8.tar.gz ]; then #检测libmcrypt-2.5.8.tar.gz是否存在
echo "libmcrypt-2.5.8.tar.gz [found]" #检测到存在,则在屏幕上输出libmcrypt-2.5.8.tar.gz找到
else
echo "Error: libmcrypt-2.5.8.tar.gz not found!!!download now......" #没找到,则报错:libmcrypt-2.5.8.tar.gz没有找到,脚本自动去网上下载libmcrypt-2.5.8.tar.gz
wget -c http://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz #用wget工具从网上下载libmcrypt-2.5.8.tar.gz
fi
if [ -s mhash-0.9.9.9.tar.gz ]; then #检测mhash-0.9.9.9.tar.gz是否存在
echo "mhash-0.9.9.9.tar.gz [found]" #检测到存在,则在屏幕上输出mhash-0.9.9.9.tar.gz找到
else
echo "Error: mhash-0.9.9.9.tar.gz not found!!!download now......" #没找到,则报错:mhash-0.9.9.9.tar.gz没有找到,脚本自动去网上下载mhash-0.9.9.9.tar.gz
wget -c http://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gz #用wget工具从网上下载mhash-0.9.9.9.tar.gz
fi
if [ -s mcrypt-2.6.8.tar.gz ]; then #检测mcrypt-2.6.8.tar.gz是否存在本文出处:www.ksharpdabu.info
echo "mcrypt-2.6.8.tar.gz [found]" #检测到存在,则在屏幕上输出mcrypt-2.6.8.tar.gz找到
else
echo "Error: mcrypt-2.6.8.tar.gz not found!!!download now......" #没找到,则报错:mcrypt-2.6.8.tar.gz没有找到,脚本自动去网上下载mcrypt-2.6.8.tar.gz
wget -c http://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gz #用wget工具从网上下载mcrypt-2.6.8.tar.gz
fi
if [ -s phpmyadmin-latest.tar.gz ]; then #检测phpmyadmin-latest.tar.gz是否存在
echo "phpmyadmin-latest.tar.gz [found]" #检测到存在,则在屏幕上输出phpmyadmin-latest.tar.gz找到
else
echo "Error: phpmyadmin-latest.tar.gz not found!!!download now......" #没找到,则报错:phpmyadmin-latest.tar.gz没有找到,脚本自动去网上下载phpmyadmin-latest.tar.gz
wget -c http://soft.vpser.net/datebase/phpmyadmin/phpmyadmin-latest.tar.gz #用wget工具从网上下载phpmyadmin-latest.tar.gz
fi
if [ -s p.tar.gz ]; then #检测p.tar.gz是否存在
echo "p.tar.gz [found]" #检测到存在,则在屏幕上输出p.tar.gz找到本文出处:www.ksharpdabu.info
else
echo "Error: p.tar.gz not found!!!download now......" #没找到,则报错:p.tar.gz没有找到,脚本自动去网上下载p.tar.gz
wget -c http://soft.vpser.net/prober/p.tar.gz #用wget工具从网上下载p.tar.gz
fi
if [ -s autoconf-2.13.tar.gz ]; then #检测autoconf-2.13.tar.gz是否存在
echo "autoconf-2.13.tar.gz [found]" #检测到存在,则在屏幕上输出autoconf-2.13.tar.gz找到
else
echo "Error: autoconf-2.13.tar.gz not found!!!download now......" #没找到,则报错:autoconf-2.13.tar.gz没有找到,脚本自动去网上下载autoconf-2.13.tar.gz
wget -c http://soft.vpser.net/lib/autoconf/autoconf-2.13.tar.gz #用wget工具从网上下载autoconf-2.13.tar.gz
fi
echo "============================check files=================================="
cd $cur_dir #进入lnmp解压的文件夹内
tar zxvf autoconf-2.13.tar.gz #解包解压autoconf-2.13.tar.gz
cd autoconf-2.13/ #进入autoconf-2.13目录
./configure --prefix=/usr/local/autoconf-2.13 #设置autoconf-2.13的安装路径为/usr/local/autoconf-2.13本文出处:www.ksharpdabu.info
make && make install #编译安装
cd ../ #返回lnmp目录
tar zxvf libiconv-1.14.tar.gz #解包解压libiconv-1.14.tar.gz
cd libiconv-1.14/ #进入libiconv-1.14目录
./configure #编译安装
make && make install
cd ../ #返回lnmp目录
cd $cur_dir #返回lnmp目录
tar zxvf libmcrypt-2.5.8.tar.gz #解包解压libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/ #进入libmcrypt-2.5.8目录
./configure #编译安装libmcrypt-2.5.8
make && make install
/sbin/ldconfig
cd libltdl/ #进入libltdl目录
./configure --enable-ltdl-install #编译安装libltdl
make && make install
cd ../../
cd $cur_dir #这段就是安装mhash-0.9.9.9
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la #将对应的库文件做软链接本文出处:www.ksharpdabu.info
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
cd $cur_dir #回到lnmp目录
tar zxvf mcrypt-2.6.8.tar.gz #解压mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/ #进入mcrypt-2.6.8
./configure #编译安装
make && make install
cd ../
if [ `getconf WORD_BIT` = ‘32‘ ] && [ `getconf LONG_BIT` = ‘64‘ ] ; then #判断Linux系统是否是64位本文出处:www.ksharpdabu.info
ln -s /usr/lib64/libpng.* /usr/lib/ #是的话,将对应的库软链接到/usr/lib/
ln -s /usr/lib64/libjpeg.* /usr/lib/
fi
ulimit -v unlimited #不限定虚拟内存大小
if [ ! `grep -l "/lib" ‘/etc/ld.so.conf‘` ]; then #判断/etc/ld.so.conf是否存在/lib
echo "/lib" >> /etc/ld.so.conf #不存在,则将/lib写进去
fi
if [ ! `grep -l ‘/usr/lib‘ ‘/etc/ld.so.conf‘` ]; then #判断/etc/ld.so.conf是否存在/usr/lib
echo "/usr/lib" >> /etc/ld.so.conf #不存在,则将/usr/lib写进去
fi
if [ -d "/usr/lib64" ] && [ ! `grep -l ‘/usr/lib64‘ ‘/etc/ld.so.conf‘` ]; then #判断是否同时存在/usr/lib64目录和在/etc/ld.so.conf‘中存在/usr/lib64行
echo "/usr/lib64" >> /etc/ld.so.conf #不存在,则将/usr/lib64写进去
fi
if [ ! `grep -l ‘/usr/local/lib‘ ‘/etc/ld.so.conf‘` ]; then #判断/etc/ld.so.conf是否存在/usr/local/lib本文出处:www.ksharpdabu.info
echo "/usr/local/lib" >> /etc/ld.so.conf #不存在,则将/usr/local/lib写进去
fi
ldconfig #更新库缓存
cat >>/etc/security/limits.conf<<eof #这段是设置系统连接数的相关参数,这里不详细介绍了,大家可以google limits.conf文件的详细配置参数和意义
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
eof
cat >>/etc/sysctl.conf<<eof
fs.file-max=65535
eof
echo "============================mysql install==================================" #这段是myslq的编译安装本文出处:www.ksharpdabu.info
cd $cur_dir
tar zxvf mysql-5.1.60.tar.gz
cd mysql-5.1.60/
if [ $installinnodb = "y" ]; then
./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-assembler --with-mysqld-ldflags=-all-static --with-charset=utf8 --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase
else
./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-assembler --with-mysqld-ldflags=-all-static --with-charset=utf8 --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
fi
make && make install
cd ../
groupadd mysql #增加mysql组
useradd -s /sbin/nologin -M -g mysql mysql #新建一个用户加入mysql组,并防止mysql这个账号登陆shell进行操作(为了系统安全)
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
sed -i ‘s/skip-locking/skip-external-locking/g‘ /etc/my.cnf
if [ $installinnodb = "y" ]; then
sed -i ‘s:#innodb:innodb:g‘ /etc/my.cnf #开启innodb引擎
fi
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R mysql /usr/local/mysql/var #将mysql的相关目录变为mysql这个用户和用户组
chgrp -R mysql /usr/local/mysql/.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql #设置mysql开机启动本文出处:www.ksharpdabu.info
chmod 755 /etc/init.d/mysql
cat > /etc/ld.so.conf.d/mysql.conf<<EOF
/usr/local/mysql/lib/mysql
/usr/local/lib
EOF
ldconfig
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
/etc/init.d/mysql start
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
/usr/local/mysql/bin/mysqladmin -u root password $mysqlrootpwd
cat > /tmp/mysql_sec_script<<EOF
use mysql;
update user set password=password(‘$mysqlrootpwd‘) where user=‘root‘;
delete from user where not (user=‘root‘) ;
delete from user where user=‘root‘ and password=‘‘;
drop database test;
DROP USER ‘‘@‘%‘;
flush privileges;
EOF
/usr/local/mysql/bin/mysql -u root -p$mysqlrootpwd -h localhost < /tmp/mysql_sec_script
rm -f /tmp/mysql_sec_script
/etc/init.d/mysql restart
/etc/init.d/mysql stop
echo "============================mysql intall completed========================="
echo "============================php+eaccelerator install======================"
cd $cur_dir
export PHP_AUTOCONF=/usr/local/autoconf-2.13/bin/autoconf
export PHP_AUTOHEADER=/usr/local/autoconf-2.13/bin/autoheader
tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17/
wget -c http://soft.vpser.net/web/php/bug/php-5.2.17-max-input-vars.patch
patch -p1 < php-5.2.17-max-input-vars.patch
./buildconf --force
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic
make ZEND_EXTRA_LIBS=‘-liconv‘
make install
mkdir -p /usr/local/php/etc
cp php.ini-dist /usr/local/php/etc/php.ini
cd ../
ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/bin/phpize /usr/bin/phpize
ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm
cd $cur_dir
tar zxvf memcache-3.0.6.tgz
cd memcache-3.0.6/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
cd $cur_dir/php-5.2.17/ext/pdo_mysql/
/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 $cur_dir/
# php extensions #这段是为php开启相应的扩展的本文出处:www.ksharpdabu.info
sed -i ‘s#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\n#‘ /usr/local/php/etc/php.ini
sed -i ‘s#output_buffering = Off#output_buffering = On#‘ /usr/local/php/etc/php.ini
sed -i ‘s/post_max_size = 8M/post_max_size = 50M/g‘ /usr/local/php/etc/php.ini
sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 50M/g‘ /usr/local/php/etc/php.ini
sed -i ‘s/;date.timezone =/date.timezone = PRC/g‘ /usr/local/php/etc/php.ini
sed -i ‘s/short_open_tag = Off/short_open_tag = On/g‘ /usr/local/php/etc/php.ini
sed -i ‘s/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g‘ /usr/local/php/etc/php.ini
sed -i ‘s/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g‘ /usr/local/php/etc/php.ini
sed -i ‘s/max_execution_time = 30/max_execution_time = 300/g‘ /usr/local/php/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,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen/g‘ /usr/local/php/etc/php.ini
if [ `getconf WORD_BIT` = ‘32‘ ] && [ `getconf LONG_BIT` = ‘64‘ ] ; then
wget -c http://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
mkdir -p /usr/local/zend/
cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/
else
wget -c http://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
mkdir -p /usr/local/zend/
cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/
fi
cat >>/usr/local/php/etc/php.ini<<EOF
;eaccelerator
;ionCube
[Zend Optimizer]
zend_optimizer.optimization_level=1
zend_extension="/usr/local/zend/ZendOptimizer.so"
EOF
groupadd www #增加www组
useradd -s /sbin/nologin -g www www #增加www用户,并且禁止shell登陆操作
mkdir -p /home/wwwroot
chmod +w /home/wwwroot
mkdir -p /home/wwwlogs
chmod 777 /home/wwwlogs
chown -R www:www /home/wwwroot
rm -f /usr/local/php/etc/php-fpm.conf
cp conf/php-fpm.conf /usr/local/php/etc/php-fpm.conf
wget -c http://soft.vpser.net/lnmp/ext/init.d.php-fpm5.2
cp init.d.php-fpm5.2 /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
echo "============================php+eaccelerator install completed======================"
echo "============================nginx install================================="
cd $cur_dir #这段是安装pcre-8.12 ,用来支持伪静态的本文出处:www.ksharpdabu.info
tar zxvf pcre-8.12.tar.gz
cd pcre-8.12/
./configure
make && make install
cd ../
ldconfig
tar zxvf nginx-1.0.15.tar.gz #编译安装nginx
cd nginx-1.0.15/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
make && make install
cd ../
rm -f /usr/local/nginx/conf/nginx.conf
cd $cur_dir
cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf
cp conf/dabr.conf /usr/local/nginx/conf/dabr.conf
cp conf/discuz.conf /usr/local/nginx/conf/discuz.conf
cp conf/sablog.conf /usr/local/nginx/conf/sablog.conf
cp conf/typecho.conf /usr/local/nginx/conf/typecho.conf
cp conf/wordpress.conf /usr/local/nginx/conf/wordpress.conf
cp conf/discuzx.conf /usr/local/nginx/conf/discuzx.conf
cp conf/none.conf /usr/local/nginx/conf/none.conf
cp conf/wp2.conf /usr/local/nginx/conf/wp2.conf
cp conf/phpwind.conf /usr/local/nginx/conf/phpwind.conf
sed -i ‘s/www.lnmp.org/‘$domain‘/g‘ /usr/local/nginx/conf/nginx.conf
rm -f /usr/local/nginx/conf/fcgi.conf
cp conf/fcgi.conf /usr/local/nginx/conf/fcgi.conf
cd $cur_dir
cp lnmp /root/lnmp
chmod +x /root/lnmp
cp vhost.sh /root/vhost.sh
chmod +x /root/vhost.sh
echo "============================nginx install completed================================="
#phpinfo
cat >/home/wwwroot/phpinfo.php<<eof #这段是放php检测信息页面
<?
phpinfo();
?>
eof
#prober #这段是放php探针
cd $cur_dir
tar zxvf p.tar.gz
cp p.php /home/wwwroot/p.php
cp conf/index.html /home/wwwroot/index.html
echo "============================phpMyAdmin install================================="
#phpmyadmin #这段是安装phpmyadmin
tar zxvf phpmyadmin-latest.tar.gz
mv phpMyAdmin-3.4.8-all-languages /home/wwwroot/phpmyadmin/
cp conf/config.inc.php /home/wwwroot/phpmyadmin/config.inc.php
sed -i ‘s/LNMPORG/LNMP.org‘$RANDOM‘VPSer.net/g‘ /home/wwwroot/phpmyadmin/config.inc.php
mkdir /home/wwwroot/phpmyadmin/upload/
mkdir /home/wwwroot/phpmyadmin/save/
chmod 755 -R /home/wwwroot/phpmyadmin/
chown www:www -R /home/wwwroot/phpmyadmin/
echo "============================phpMyAdmin install completed================================="
echo "============================add nginx and php-fpm on startup============================"
echo "Download new nginx init.d file......"
wget -c http://soft.vpser.net/lnmp/ext/init.d.nginx
cp init.d.nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig --level 345 php-fpm on #设置php-fpm在3、4、5等级启动本文出处:www.ksharpdabu.info
chkconfig --level 345 nginx on #设置nginx在3、4、5等级启动
chkconfig --level 345 mysql on #设置nginx在3、4、5等级启动
echo "===========================add nginx and php-fpm on startup completed===================="
echo "Starting LNMP..." #下面是安装好后,启动nignx,mysql,php-fpm
/etc/init.d/mysql start
/etc/init.d/php-fpm start
/etc/init.d/nginx start
#add 80 port to iptables
if [ -s /sbin/iptables ]; then
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables-save
fi
echo "===================================== Check install ==================================="
clear
if [ -s /usr/local/nginx ]; then #这段就是检测lnmp安装是否成功本文出处:www.ksharpdabu.info
echo "/usr/local/nginx [found]"
else
echo "Error: /usr/local/nginx not found!!!"
fi
if [ -s /usr/local/php ]; then
echo "/usr/local/php [found]"
else
echo "Error: /usr/local/php not found!!!"
fi
if [ -s /usr/local/mysql ]; then
echo "/usr/local/mysql [found]"
else
echo "Error: /usr/local/mysql not found!!!"
fi
echo "========================== Check install ================================"
if [ -s /usr/local/nginx ] && [ -s /usr/local/php ] && [ -s /usr/local/mysql ]; then
echo "Install lnmp 0.9 completed! enjoy it."
echo "========================================================================="
echo "LNMP V0.9 for CentOS/RadHat Linux VPS Written by Licess "
echo "========================================================================="
echo ""
echo "For more information please visit http://www.lnmp.org/"
echo ""
echo "lnmp status manage: /root/lnmp {start|stop|reload|restart|kill|status}"
echo "default mysql root password:$mysqlrootpwd"
echo "phpinfo : http://$domain/phpinfo.php"
echo "phpMyAdmin : http://$domain/phpmyadmin/"
echo "Prober : http://$domain/p.php"
echo "Add VirtualHost : /root/vhost.sh"
echo ""
echo "The path of some dirs:"
echo "mysql dir: /usr/local/mysql"
echo "php dir: /usr/local/php"
echo "nginx dir: /usr/local/nginx"
echo "web dir : /home/wwwroot"
echo ""
echo "========================================================================="
/root/lnmp status
netstat -ntl
else #如果lnmp安装失败,提示下面的信息
echo "Sorry,Failed to install LNMP!"
echo "Please visit http://bbs.vpser.net/forum-25-1.html feedback errors and logs."
echo "You can download lnmp.log from your server,and upload lnmp.log to LNMP Forum."
fi
fi
以上是关于shell-网上lnmp一键安装讲解的主要内容,如果未能解决你的问题,请参考以下文章