您的位置:首页 > 其它

一键安装lnmp脚本

2015-12-04 16:37 357 查看
仍需完善...........

#!/bin/bash
# -------------------------------------------------------------------------------
# Filename:    install.sh
# Revision:    1.1
# Date:        2015/12/04
# Author:      ley
# Email:       xxx
# Website:     www.xxx.com
# Description: Install mysql,php,nginx
# Notes:       xxxxxxx
# -------------------------------------------------------------------------------
# Copyright:   20xx (c) ley
#Version 1.0
#The first one , can monitor the system memory
#Version 1.1
#Modify the method of the script ,more fast
#--------------------------------------------------------------------------------

mysql_filename="mysql-5.5.33-linux2.6-x86_64.tar.gz"
php_filename="php-5.5.3.tar.bz2"
nginx_filename="nginx-1.8.0.tar.gz"

yum install gcc-c++ ncurses-deve  libaio*  libxml2-devel libjpeg-devel libpng-devel freetype-devel libcurl* libmcr* pcre-devel -y

##安装Mysql
cd /home

tar zxf $mysql_filename

mv mysql-5.5.33-linux2.6-x86_64 /usr/local/mysql

useradd -s /sbin/nologin mysql
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
cd /usr/local/mysql/

./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

cp -r support-files/my-large.cnf /etc/my.cnf
cp -r support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld

sed -i "25abasedir=/usr/local/mysql" /etc/my.cnf
sed -i "26adatadir=/data/mysql" /etc/my.cnf

ln -s /usr/local/mysql/bin/mysql /usr/bin/
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/
ln -s /usr/local/mysql/bin/mysqladmin  /usr/bin/
/etc/init.d/mysqld start
mysqladmin -u root password "root"

mysql_port=`netstat -lntup|grep 3306|awk '{print $4}'|cut -c 9-12`

if [ $mysql_port == 3306 ];then

echo "mysql install sucessful!"

else

echo "mysql install failed"

fi

##安装Php

cd /home

useradd -s /sbin/nologin php-fpm
tar jxf $php_filename
cd php-5.5.3
./configure --prefix=/usr/local/php-fpm   --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm  --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-curl

make && make install

cp -r php.ini-production /usr/local/php-fpm/etc/php.ini
cp -r sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp -r /usr/local/php-fpm/etc/php-fpm.conf.default /usr/local/php-fpm/etc/php-fpm.conf

chmod 755 /etc/init.d/php-fpm
service php-fpm start

php_port=`netstat -lntup|grep 9000|awk '{print $4}'|cut -c 11-14`

if [ $php_port == 9000 ];then

echo "php install sucessful!"

else

echo "php install failed"

fi

##安装Nginx

cd /home

tar zxf $nginx_filename
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx
make && make install

/usr/local/nginx/sbin/nginx

nginx_port=`netstat -lntup|grep 80|grep -v udp|awk '{print $4}'|cut -c 9-11`

if [ $nginx_port == 80 ];then

echo "nginx install sucessful!"

else

echo "nginx install failed"

fi


本文出自 “9527” 博客,请务必保留此出处http://liangey.blog.51cto.com/9097868/1719636
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: