写在前边:

以前安装lnmp总是一个一个安装很耗时而且经常出错,于是在网上搜啊搜的,搜不到一个适合arch安装的一键傻瓜安装脚本,于是在网上搜索了一个其他系统的稍作修改而成。

本脚本是按照http://www.lnmp.org中centos.sh修改而成。所用软件全部为源码安装

因为是源码安装所以基本上之需要把启动脚本的位置init.d替换为arch中的rc.d即可。

编译的时候mysql可能会比较耗时,推荐替换pacman安装。再去掉相应的设置即可。

codewalker@codehost:/tmp/lnmp0.9

$ cat archos.sh 

#!/bin/bash

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

# Check if user is root

if [ $(id -u) != “0” ]; then

    echo “Error: You must be root to run this script, please use root to install lnmp”

    exit 1

fi

clear

echo “=========================================================================”

echo “LNMP V0.0.1 for Archlinux base on Licess Written by codewalkertse”

echo “=========================================================================”

echo “A tool to auto-compile & install Nginx+MySQL+PHP on Linux “

echo “=========================================================================”

cur_dir=$(pwd)

if [ “$1” != “–help” ]; then

#set main domain name

domain=”www.lnmp.org

echo “Please input domain:”

read -p “(Default domain: www.lnmp.org):” domain

if [ “$domain” = “” ]; then

domain=”www.lnmp.org

fi

echo “===========================”

echo domain=”$domain”

echo “===========================”

#set mysql root password

echo “===========================”

mysqlrootpwd=”root”

echo “Please input the root password of mysql:”

read -p “(Default password: root):” mysqlrootpwd

if [ “$mysqlrootpwd” = “” ]; then

mysqlrootpwd=”root”

fi

echo “===========================”

echo mysqlrootpwd=”$mysqlrootpwd”

echo “===========================”

#do you want to install the InnoDB Storage Engine?

echo “===========================”

installinnodb=”n”

echo “Do you want to install the InnoDB Storage Engine?”

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)

echo “You will install the InnoDB Storage Engine”

installinnodb=”y”

;;

n|N|No|NO|no|nO)

echo “You will NOT install the InnoDB Storage Engine!”

installinnodb=”n”

;;

*)

echo “INPUT error,The InnoDB Storage Engine will NOT install!”

installinnodb=”n”

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

pacman -R httpd*

pacman -R php*

pacman -R mysql-server mysql

pacman -R php-mysql

pacman -Syu

#Disable SeLinux

if [ -s /etc/selinux/config ]; then

sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

fi

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;

do pacman -S $packages; done

echo “============================check files==================================”

if [ -s php-5.2.17.tar.gz ]; then

  echo “php-5.2.17.tar.gz [found]“

  else

  echo “Error: php-5.2.17.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/web/php/php-5.2.17.tar.gz

fi

if [ -s php-5.2.17-fpm-0.5.14.diff.gz ]; then

  echo “php-5.2.17-fpm-0.5.14.diff.gz [found]“

  else

  echo “Error: php-5.2.17-fpm-0.5.14.diff.gz not found!!!download now……”

  wget -c http://soft.vpser.net/web/phpfpm/php-5.2.17-fpm-0.5.14.diff.gz

fi

if [ -s memcache-3.0.6.tgz ]; then

  echo “memcache-3.0.6.tgz [found]“

  else

  echo “Error: memcache-3.0.6.tgz not found!!!download now……”

  wget -c http://soft.vpser.net/web/memcache/memcache-3.0.6.tgz

fi

if [ -s pcre-8.12.tar.gz ]; then

  echo “pcre-8.12.tar.gz [found]“

  else

  echo “Error: pcre-8.12.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/web/pcre/pcre-8.12.tar.gz

fi

if [ -s nginx-1.0.15.tar.gz ]; then

  echo “nginx-1.0.15.tar.gz [found]“

  else

  echo “Error: nginx-1.0.15.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/web/nginx/nginx-1.0.15.tar.gz

fi

if [ -s mysql-5.1.60.tar.gz ]; then

  echo “mysql-5.1.60.tar.gz [found]“

  else

  echo “Error: mysql-5.1.60.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/datebase/mysql/mysql-5.1.60.tar.gz

fi

if [ -s libiconv-1.14.tar.gz ]; then

  echo “libiconv-1.14.tar.gz [found]“

  else

  echo “Error: libiconv-1.14.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/web/libiconv/libiconv-1.14.tar.gz

fi

if [ -s libmcrypt-2.5.8.tar.gz ]; then

  echo “libmcrypt-2.5.8.tar.gz [found]“

  else

  echo “Error: libmcrypt-2.5.8.tar.gz not found!!!download now……”

  wget -c  http://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz

fi

if [ -s mhash-0.9.9.9.tar.gz ]; then

  echo “mhash-0.9.9.9.tar.gz [found]“

  else

  echo “Error: mhash-0.9.9.9.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gz

fi

if [ -s mcrypt-2.6.8.tar.gz ]; then

  echo “mcrypt-2.6.8.tar.gz [found]“

  else

  echo “Error: mcrypt-2.6.8.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gz

fi

if [ -s phpmyadmin-latest.tar.gz ]; then

  echo “phpmyadmin-latest.tar.gz [found]“

  else

  echo “Error: phpmyadmin-latest.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/datebase/phpmyadmin/phpmyadmin-latest.tar.gz

fi

if [ -s p.tar.gz ]; then

  echo “p.tar.gz [found]“

  else

  echo “Error: p.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/prober/p.tar.gz

fi

if [ -s autoconf-2.13.tar.gz ]; then

  echo “autoconf-2.13.tar.gz [found]“

  else

  echo “Error: autoconf-2.13.tar.gz not found!!!download now……”

  wget -c http://soft.vpser.net/lib/autoconf/autoconf-2.13.tar.gz

fi

echo “============================check files==================================”

cd $cur_dir

tar zxvf autoconf-2.13.tar.gz

cd autoconf-2.13/

./configure –prefix=/usr/local/autoconf-2.13

make && make install

cd ../

tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14/

./configure

make && make install

cd ../

cd $cur_dir

tar zxvf 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 ../../

cd $cur_dir

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

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

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

./configure

make && make install

cd ../

if [ `getconf WORD_BIT` = ‘32’ ] && [ `getconf LONG_BIT` = ‘64’ ] ; then

        ln -s /usr/lib64/libpng.* /usr/lib/

        ln -s /usr/lib64/libjpeg.* /usr/lib/

fi

ulimit -v unlimited

if [ ! grep -l "/lib"    '/etc/ld.so.conf' ]; then

echo “/lib” >> /etc/ld.so.conf

fi

if [ ! grep -l '/usr/lib'    '/etc/ld.so.conf' ]; then

echo “/usr/lib” >> /etc/ld.so.conf

fi

if [ -d “/usr/lib64” ] && [ ! grep -l '/usr/lib64'    '/etc/ld.so.conf' ]; then

echo “/usr/lib64” >> /etc/ld.so.conf

fi

if [ ! grep -l '/usr/local/lib'    '/etc/ld.so.conf' ]; then

echo “/usr/local/lib” >> /etc/ld.so.conf

fi

ldconfig

cat >>/etc/security/limits.conf<<eof

* 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==================================”

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

useradd -s /sbin/nologin -M -g mysql mysql

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

fi

/usr/local/mysql/bin/mysql_install_db –user=mysql

chown -R mysql /usr/local/mysql/var

chgrp -R mysql /usr/local/mysql/.

cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/mysql

chmod 755 /etc/rc.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/rc.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/rc.d/mysql restart

/etc/rc.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

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

useradd -s /sbin/nologin -g www www

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/rc.d.php-fpm5.2

cp rc.d.php-fpm5.2 /etc/rc.d/php-fpm

chmod +x /etc/rc.d/php-fpm

echo “============================php+eaccelerator install completed======================”

echo “============================nginx install=================================”

cd $cur_dir

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

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

–>

分享: 分享到新浪Qing

喜欢

–>

阅读_┊_ 评论 收藏 转载 喜欢 打印举报

已投稿到:

排行榜 圈子

加载中,请稍候……

前一篇:bash script for auto install pptpd server

后一篇:关于pacman Tips 小贴士

评论 重要提示:警惕虚假中奖信息       岛国宛如仙境樱花城       关注每日最热门博客 

[发评论]

–>* 评论加载中,请稍候…
–>

发评论 最适合调情西班牙海湾       关注每日最热门博客

登录名: 密码: 找回密码 注册 记住登录状态

昵   称:

分享到微博    评论并转载此博文

验证码: 请点击后输入验证码 收听验证码

匿名评论

发评论

以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

< 前一篇bash script for auto install pptpd server

后一篇 >关于pacman Tips 小贴士

var voteid=””;