码迷,mamicode.com
首页 > 其他好文 > 详细

一键安装lnmp脚本(包括软件版本)

时间:2017-02-03 17:15:11      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:一键自动部署lnmp

直接上脚本:附件也包含脚本

#!/bin/bash

yum -y install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd  kernel keyutils  patch  perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch freetype-devel cmake zlib  ncurses* openssl*  cmake gcc* autoconf bison  libpng*

##文件请上传至/opt/soft/

cd /opt/soft/

##安装pcre支持正则

tar -zxvf pcre-8.34.tar.gz

cd pcre-8.34

./configure && make && make install

##增加www用户和组

groupadd www

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

##安装zlib 支持gzip

cd /opt/soft/

tar -zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

 ./configure && make && make install

##安装nginx

cd /opt/soft/

tar -zxvf nginx-1.11.6.tar.gz

cd nginx-1.11.6

./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  --with-pcre=/opt/soft/pcre-8.34 --with-zlib=/opt/soft/zlib-1.2.8

make && make install

###安装php支持软件

cd /opt/soft/

tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14/

 ./configure 

 sed -i s‘#_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");#//_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");#‘ srclib/stdio.h

 make && make install

 cd /opt/soft/

 ##安装libmcrypt

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure && make && make install

ldconfig 

cd libltdl/

./configure --enable-ltdl-install

make && make install

###mhash

 cd /opt/soft/

 tar zxvf mhash-0.9.9.9.tar.gz

 cd mhash-0.9.9.9

 ./configure && make && make install

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 /opt/soft/

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

ldconfig 

./configure && make && make install

###安装php

cd /opt/soft/

mkdir -p /usr/local/php/etc

tar -zxvf php-5.6.11.tar.gz

cd php-5.6.11

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --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 --enable-fileinfo --with-libdir=lib64 --enable-opcache 

echo "/usr/local/lib">>/etc/ld.so.conf

ldconfig

make ZEND_EXTRA_LIBS=‘-liconv‘

make install

##安装redis扩展

cd /opt/soft/

tar -zxvf phpredis-2.2.4.tar.gz 

cd phpredis-2.2.4

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

###安装swool

cd /opt/soft/

#yum install git -y

#git clone https://github.com/swoole/swoole-src.git

tar -zxvf  swoole-src.tar.gz

cd swoole-src/

/usr/local/php/bin/phpize 

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

cd /opt/soft/

cp /opt/soft/php.ini /usr/local/php/etc/

cp /opt/soft/php-fpm.conf   /usr/local/php/etc/

mkdir /usr/local/php/log

 mkdir /opt/web

 mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak

 cp nginx.conf /usr/local/nginx/conf/

/usr/local/nginx/sbin/nginx

/usr/local/php/sbin/php-fpm 


####安装mysql:

groupadd mysql

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

cd /opt/soft

tar -zxvf mysql-5.6.25.tar.gz 

cd mysql-5.6.25

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1

make && make install 

cp /etc/my.cnf /etc/my.cnf.bak

cd /opt/soft

cp my.cnf /etc/

##授权

cd /usr/local/mysql/

chown -R mysql .

chgrp -R mysql .

##初始化mysql:

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --defaults-file=/etc/my.cnf

##启动mysql:

/usr/local/mysql/bin/mysqld_safe  --defaults-file=/etc/my.cnf --user=mysql&

sleep 10


##修改密码

/usr/local/mysql/bin/mysqladmin  -u root password "dengchao"

/usr/local/mysql/bin/mysql  -uroot -pdengchao -e ‘grant all privileges on   *.* to root@"%" identified by "zTt20LB5" with grant option;‘

/usr/local/mysql/bin/mysql  -uroot -pdengchao -e ‘flush privileges ;‘


由于51cto限制上传50m附件,所以附件已上传至百度云:

http://pan.baidu.com/s/1pKBuCQJ

有问题,请大家多多交流

本文出自 “nginx安装优化” 博客,请务必保留此出处http://mrdeng.blog.51cto.com/3736360/1894623

一键安装lnmp脚本(包括软件版本)

标签:一键自动部署lnmp

原文地址:http://mrdeng.blog.51cto.com/3736360/1894623

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!