`
zhengdl126
  • 浏览: 2531867 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类

用nginx_php 自动安装LNMP

阅读更多

http://www.freebsdsystem.org/nginx_php_shell/

此脚本在生产服务器上使用了一年多,本脚本崇尚简单唯美,只需要一个脚本就可以在任何一台有网络的服务器上自动配置LNMP。使用方法:chmod u+x nginx_php; ./nginx_php init|ins_mysql-server|ins_mysql-client|ins_php52|ins_php52-ext|ins_mysql
本脚本会在脚本执行目录下,建packages用于存放LNMP所需要的软件。大家安装完可以删除该目录。





#/bash
# author:coralzd powered by www.freebsdsystem.org
# written by coralzd 2011.05.05
# version 0.1.3 build 20110505


nginx_dir="/usr/local/nginx"
php52_dir="/usr/local/php52"
mysql_dir="/usr/local/mysql"

function init()
{

LANG=C
yum -y install wget 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 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

read -p "Now,will download nginxphp software...Y|y:" nginxphp

case "$nginxphp" in

Y|y)

echo -n "starting download nginx_php ..."
cat > list << "EOF" &&
nginx-1.0.0.tar.gz
php-5.2.17.tar.gz
php-5.2.17-fpm-0.5.14.diff.gz
libiconv-1.13.1.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
memcache-2.2.5.tgz
mhash-0.9.9.9.tar.gz
mysql-5.1.52.tar.gz
pcre-8.10.tar.gz
eaccelerator-0.9.6.1.tar.bz2
PDO_MYSQL-1.0.2.tgz
libunwind-0.99.tar.gz
ImageMagick.tar.gz
imagick-2.3.0.tgz
google-perftools-1.6.tar.gz
fcgi.conf
php.ini
nginx.conf
php-fpm.conf
EOF
mkdir packages
for i in `cat list`
do
if [ -s packages/$i ]; then
echo "$i [found]"
else
echo "Error: $i not found!!!download now......"
wget http://www.freebsdsystem.org/linux/nginx-php/$i -P packages/
fi
done
;;

*)

echo -n "exit install script"
exit 0
;;

esac

groupadd www && useradd www -s /sbin/nologin -g www
groupadd mysql && useradd mysql -s /sbin/nologin -g mysql
echo "www and mysql user && group create!"

/bin/rm -rf list

echo -e "All of installed sucussful!"


}
function is_version()

{


if [ `uname -m` == "x86_64" ];then
tar zxf libunwind-0.99.tar.gz
tar zxvf libunwind-0.99.tar.gz
cd libunwind-0.99/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install
cd ../
else

echo "your system is 32bit ,not install libunwind lib!"
fi


}

function ins_nginx()

{

cd packages

is_version
tar zxf google-perftools-1.6.tar.gz
cd google-perftools-1.6
./configure
make
make install

cd ..
tar zxf pcre-8.10.tar.gz
cd pcre-*
./configure
make
make install
cd ..
tar zxf nginx-1.0.0.tar.gz
cd nginx-1.0.0
./configure --prefix=${nginx_dir} --with-google_perftools_module --user=www --group=www --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module

make && make install
cd ..
rm -rf /usr/local/nginx/conf/nginx.conf
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
cp nginx.conf /usr/local/nginx/conf/
cp fcgi.conf /usr/local/nginx/conf/
echo "nginx installed sucussfully!"

}


function ins_mysql-server()
{

cd packages/
tar zxf mysql-5.1.52.tar.gz
cd mysql-5.1.52
CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe"
CXXFLAGS="${CFLAGS}"
./configure "--prefix=${mysql_dir}" "--with-server-suffix=-DZWWW" "--with-mysqld-user=mysql" "--without-debug" "--with-charset=utf8" "--with-extra-charsets=all" "--with-pthread" "--with-big-tables" "--enable-thread-safe-client" "--enable-assembler" "--with-readline" "--with-ssl" "--enable-local-infile" "--with-plugins=partition,myisammrg" "--without-ndb-debug"

make && make install
cp support-*/mysql.server /etc/init.d/mysqld
cd /usr/local/mysql
chown -R mysql:mysql .
rm -rf sql-bench mysql-test
echo "mysql server 5.1.52 installed successfully!"
}


function ins_mysql-client()
{

cd packages/
tar zxf mysql-5.1.52.tar.gz
cd mysql-5.1.52
CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe"
CXXFLAGS="${CFLAGS}"
./configure "--prefix=${mysql_dir}" "--with-mysqld-user=mysql" "--without-debug" "--with-charset=utf8" "--with-extra-charsets=all" "--with-pthread" "--with-big-tables" "--enable-thread-safe-client" "--enable-assembler" "--with-readline" "--with-ssl" "--enable-local-infile" "--without-server"

make && make install
cd /usr/local/mysql
chown -R mysql:mysql .
rm -rf sql-bench mysql-test
echo "mysql client 5.1.52 installed successfully!"
}
function ins_php52()
{
cd packages/
tar zxf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../

tar zxf 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 zxf 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
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../


tar zxf 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/
./configure --prefix=${php52_dir} --with-config-file-path=${php52_dir}/etc --with-mysql=${mysql_dir} --with-mysqli=${mysql_dir}/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-discard-path --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 --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install
cd ..
cp php.ini /usr/local/php52/etc/
cp php-fpm.conf /usr/local/php52/etc/

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf.d/mysql_lib.conf
/sbin/ldconfig
echo "php52 installed successfully!"
}

function ins_php52-ext()

{
cd packages/

tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5/
${php52_dir}/bin/phpize
./configure --with-php-config=${php52_dir}/bin/php-config
make
make install
cd ../

tar jxf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
${php52_dir}/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=${php52_dir}/bin/php-config
make
make install
cd ../

tar zxf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
${php52_dir}/bin/phpize
./configure --with-php-config=${php52_dir}/bin/php-config --with-pdo-mysql=${mysql_dir}
make
make install
cd ../

tar zxf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../

tar zxf imagick-2.3.0.tgz
cd imagick-2.3.0/
${php52_dir}/bin/phpize
./configure --with-php-config=${php52_dir}/bin/php-config
make
make install
cd ../


echo "php52 extension installed successfully!"


}

case $1 in


init)

init
;;
ins_mysql-server)

ins_mysql-server

;;
ins_mysql-client)
ins_mysql-client
;;
ins_nginx)
ins_nginx
;;
ins_php52)
ins_php52
;;
ins_php52-ext)
ins_php52-ext
;;
*)

echo "Usage:`basename $0` {init|ins_mysql-server|ins_mysql-client|ins_php52|ins_php52-ext|ins_mysql}"
;;
esac

分享到:
评论

相关推荐

    一个简洁的全自动安装LNMP服务器环境的Shell脚本分享

    本文将详细介绍一个简洁的全自动安装LNMP(Linux + Nginx + MySQL + PHP)服务器环境的Shell脚本。这个脚本已经在生产环境中稳定运行了一年多,以其简单的代码和高效的自动化配置获得了赞誉。对于那些需要快速部署...

    lnmp安装(nginx mysql php )

    安装完成后,可以通过`systemctl start nginx`启动Nginx服务,并使用`systemctl status nginx`检查其状态。为了使Nginx在系统启动时自动启动,执行`systemctl enable nginx`。 接下来是MySQL,这是一个开源的关系型...

    基于Linux系统Nginx的动态网站的LNMP环境源码包

    在Linux上,安装PHP可以使用`apt-get install php-fpm`或`yum install php-fpm`,并确保PHP-FPM服务启动并配置为自动启动。配置Nginx以代理PHP请求到PHP-FPM,可以在Nginx配置文件中添加`location ~ \.php$`的规则,...

    LNMP(Nginx/MySQL/PHP)

    LNMP(Nginx/MySQL/PHP) LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。...Nginx 用C编写,不论是系统资源开销还是CPU使用效率都比Perlbal要好的多。 作为邮件代理服务器:Nginx同时也是一

    Ubuntu Debian(NGINX/PHP/MYSQL)快速配置工具LNMP云安装

    Debian6系统下使用之前发布的“DebianLNMP”服务器软件套件,DebianLNMP一键安装包是一个快捷的服务器套件,轻轻松松全自动安装LNMP(Nginx、MySQL、PHP、phpMyAdmin)可直接用再生产环境。现在我们已经在Debian/...

    CentOS_6搭建LNMP标准生产环境

    在本文中,我们将详细讨论如何在CentOS 6.5系统上搭建一个LNMP(Linux, Nginx, MySQL, PHP)的标准生产环境。这个过程包括了多个步骤,确保服务器的安全性、稳定性和高效运行。 首先,我们要配置iptables防火墙,以...

    Nginx+php(FastCGI)一键安装

    本教程将详细介绍如何在Linux系统上进行Nginx+php-FastCGI的一键安装,以及添加memcache缓存服务和部署Discuz论坛系统,打造LAMP(Linux + Apache + MySQL + PHP)架构的替代方案——LNMP(Linux + Nginx + MySQL + ...

    lnmp部署代码(脚本自动化)

    安装过程中使用了之前配置好的自定义YUM源,并安装了一系列与LNMP56相关的软件包,包括Nginx、PHP及其扩展模块等。安装完成后,还会自动启动相关服务,并输出安装操作所花费的时间。 #### 六、初始化MySQL ```bash...

    Centos 7.4 LNMP架构_部署 glpi 9.4.3.docx

    运行安装脚本后,您的系统上将会自动安装 Nginx、PHP 和 MySQL,并进行基本配置。 **2. 配置 MySQL 数据库** 接下来,我们需要登录MySQL服务器,创建一个名为 `glpi` 的数据库,并为该数据库创建一个用户。执行...

    自动化安装lnmp

    在centos7中安装nginx服务,alisql服务,php服务,dvwa服务,实现lnmp。需要提前将相应安装包下载到/usr/local/src/目录下

    centos7安装LNMP服务器教程

    安装完成后,设置 Nginx 在系统启动时自动运行,并启动 Nginx 服务: ```bash chkconfig nginx on service nginx start ``` #### 六、安装 PHP-FPM 安装 PHP-FPM 及其依赖库: ```bash yum install php-fpm ``` ...

    ubuntu自动安装nginx php脚本

    ubuntu自动安装nginx php脚本ubuntu自动安装nginx php脚本

    阿里云 安装lnmp_201712251

    使用阿里云的一键部署功能,可以快速搭建 LNMP 环境,包括安装 CentOS 6.5 操作系统、Nginx Web 服务器、MySQL 5.7 数据库和 PHP 7.1 编程语言。 二、MySQL 备份 MySQL 备份是数据库管理的重要步骤,用于防止数据...

    一键安装lnmp环境

    在Linux系统中,手动配置LNMP环境涉及多个步骤,包括安装Linux操作系统、Nginx、MySQL、PHP及其依赖,以及配置各个组件之间的通信。而"一键安装"就是通过一个自动化脚本,简化了这个过程,使得非专业用户也能轻松...

    lnmp: php7.1+nginx1.11+mysql5.6+yaf+redis

    LNMP(Linux + Nginx + MySQL + PHP)是一个常见的Web服务器组合,广泛应用于网站开发和部署。在这个环境中,PHP7.1、Nginx1.11、MySQL5.6以及Yaf(Yet Another Framework)和Redis是关键组件。下面将详细解释这些...

    DebianLNMP加强版一键安装包Debian6配置Nginx+PHP5.3+MySQL最快最新

    DebianLNMP加强版? 新增PHP5插件ImageMagick、XCache、memcache、curl、MCrypt、Suhosin。...DebianLNMP一键安装包是很不错的安装脚本,用在低配置VPS上最合适不过啦,安装方便快捷,轻轻松松全自动安装LNMP.

    Linux+Nginx+MySQL+PHP一体化安装脚本

    LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat/Fedora、Debian/Ubuntu/Raspbian VPS(VDS)或独立主机安装LNMP(Nginx/MySQL/PHP)、LNMPA(Nginx/MySQL/PHP/Apache)、LAMP(Apache/MySQL/PHP)生产环境的...

Global site tag (gtag.js) - Google Analytics