常用脚本lnmp
3)安装lnmp脚本只供参考需修改相应参数
#!/bin/bash
#Function: Install LNMP
#Author: wang
#Date: 20170809
nginx_install(){
useradd www -u 509 -s /bin/bash -m
mkdir -p /opt/server/nginx/temp
#Install the make GCC
yum -y install gcc gcc-c++ automake autoconf libtool make
#Installing PCRE library (to rewrite)
cd /root/package
echo "Start installing PCRE..."
#wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz #shixiao
#wget http://120.52.73.48/jaist.dl.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
tar fxz pcre-8.37.tar.gz
cd pcre-8.37
./configure
make && make install
A=`echo $?`
if [ $A == 0 ];then
echo "The GCC has been successfully installed !!!"
cd ..
else
echo "GCC installed there is a problem, the script will exit !!!"
exit 1
fi
#Install zlib library (for gzip compression)
echo "Start the installation zlib library..."
#wget http://zlib.net/zlib-1.2.8.tar.gz
tar fxz zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make && make install
B=`echo $?`
if [ $B == 0 ];then
echo "Zlib has been successfully installed !!!"
cd ..
else
echo "Zlib installed there is a problem, the script will exit !!!"
exit 1
fi
#Install the SSL
echo "Install the SSL ..."
#wget http://www.openssl.org/source/openssl-1.0.1p.tar.gz -P /usr/local/src/
mv /root/package/openssl-1.0.1p.tar.gz /usr/local/src
cd /usr/local/src
tar fxz openssl-1.0.1p.tar.gz
cd openssl-1.0.1p
./config
make && make install
C=`echo $?`
if [ $C == 0 ];then
echo "SSL has been successfully installed !!!"
cd /root/package
else
echo "SSL installed there is a problem, the script will exit !!!"
exit 1
fi
#Install nginx
echo "Begin to install nginx ..."
#wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar fxz nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure --prefix=/opt/server/nginx \
--user=www \
--group=www \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_sub_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_spdy_module \
--with-ipv6 \
--http-fastcgi-temp-path=/opt/server/nginx/temp/fastcgi \
--http-client-body-temp-path=/opt/server/nginx/temp/client \
--http-proxy-temp-path=/opt/server/nginx/temp/proxy \
--http-scgi-temp-path=/opt/server/nginx/temp/scgi \
--http-uwsgi-temp-path=/opt/server/nginx/temp/uwsgi \
--with-openssl=/usr/local/src/openssl-1.0.1p
make && make install
D=`echo $?`
if [ $D == 0 ];then
echo "Nginx successful installation !!!"
cd ..
else
echo "Nginx installation has a problem, the script exits !!!"
exit 1
fi
cd /lib64
ln -s libpcre.so.0.0.1 libpcre.so.1
#To optimize configuration file nginx.conf
cat > /opt/server/nginx/conf/nginx.conf << EOF
user www;
worker_processes 4;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 20480;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
sendfile on;
tcp_nopush on;
keepalive_timeout 6;
tcp_nodelay on;
client_header_timeout 15;
client_body_timeout 15;
send_timeout 15;
client_max_body_size 10m;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 2048k;
fastcgi_buffers 4 2048k;
fastcgi_busy_buffers_size 2048k;
fastcgi_temp_file_write_size 2048k;
gzip on;
gzip_buffers 4 32k;
gzip_comp_level 9;
gzip_min_length 1k;
gzip_http_version 1.1;
gzip_types text/css text/xml application/javascript application/msword application/pdf;
allow 182.18.19.162; #gongsi
allow 211.157.168.138; #gongsi
# deny all;
include /opt/server/nginx/vhosts/*.conf;
}
EOF
mkdir /opt/server/nginx/vhosts -p
touch /opt/server/nginx/vhosts/fengkong.conf
cat > /opt/server/nginx/vhosts/fengkong.conf << EOF
log_format fengkong.wanglibao.com
'\$http_x_forwarded_for - \$remote_addr [\$time_local] "\$request" '
'\$status \$body_bytes_sent "\$http_referer" '
'"\$http_user_agent" \$http_x_clientip';
server {
listen 80;
server_name fengkong.wanglibao.com;
access_log logs/fengkong.wanglibao.com.access.log fengkong.wanglibao.com;
error_log logs/fengkong.wanglibao.com.error.log error;
root /app/fengkong/web;
location / {
index admin.php index.php index.html index.htm;
}
location ~ \.php\$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /app/fengkong/web\$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(git|svn|gitignore)\$ {
deny all;
}
}
EOF
#Start the nginx
echo "Start the nginx..."
/opt/server/nginx/sbin/nginx
netstat -ntpl
}
php_install(){
#Install some libraries
echo "===========Install some libraries...============"
yum install epel-release -y
yum -y install libmcrypt-devel mhash-devel libxslt-devel 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 libiconv readline-devel gdbm-devel
#Installing PHP
echo "================Installing PHP...==================="
cd /root/package/
mkdir -p /opt/server/php
#wget http://cn2.php.net/distributions/php-5.6.14.tar.gz
tar fxz php-5.6.14.tar.gz
cd php-5.6.14
./configure \
--prefix=/opt/server/php \
--with-mysql=/opt/server/mysql \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-pdo \
--with-freetype-dir \
--with-png-dir \
--with-libxml-dir=/usr \
--enable-xml \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-fpm \
--with-mcrypt \
--with-gettext \
--enable-mbstring \
--with-curl \
--with-curlwrappers \
--disable-debug \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--with-xmlrpc \
--enable-dba \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--with-mhash \
--with-gdbm \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--with-pcre-regex \
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir \
--with-openssl \
--enable-ftp \
--with-readline \
--enable-shared \
--with-pear \
--with-iconv
make
make install
A=`echo $?`
if [ $A == 0 ];then
echo "=============PHP installation is successful!!!============="
else
echo "=============PHP installation failure!!!=============="
exit 1
fi
#Configure PHP-FPM
echo "===============Configure PHP-FPM...================"
/bin/cp /root/package/php-5.6.14/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /root/package/php-5.6.14/php.ini-production /opt/server/php/lib/php.ini
chmod +x /etc/init.d/php-fpm
chkconfig --add /etc/init.d/php-fpm
chkconfig php-fpm on
cd /opt/server/php/etc
/bin/cp php-fpm.conf.default php-fpm.conf
cat >php-fpm.conf<<EOF
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = error
rlimit_files = 32768
[www]
user = www
group = www
listen = 127.0.0.1:9000
listen.owner = www
listen.group = www
pm = dynamic
pm.max_children = 1024
pm.start_servers = 16
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.process_idle_timeout = 15s;
pm.max_requests = 2048
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
slowlog = /opt/server/php/var/log/$HOSTNAME.log.slow
request_slowlog_timeout = 3
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f dengyong@wanglibank.com
EOF
#Install the pdo module
echo "=============Install the pdo module !!! ====================="
cd /root/package/php-5.6.14/ext/pdo
/opt/server/php/bin/phpize
./configure --with-php-config=/opt/server/php/bin/php-config --enable-pdo=shared
make
make install
D=`echo $?`
if [ $D == 0 ];then
echo "=============The pdo module installation is successful !!!============="
else
echo "============The pdo module installation failed !!!=============="
exit 1
fi
#Install the pdo mysql module
echo "=================Install the pdo mysql module !!! ==========================="
cd /root/package/php-5.6.14/ext/pdo_mysql
/opt/server/php/bin/phpize
./configure --with-php-config=/opt/server/php/bin/php-config
make
make install
E=`echo $?`
if [ $E == 0 ];then
echo "=============The pdo mysql module installation is successful !!!============="
else
echo "============The pdo mysql module installation failed !!!=============="
exit 1
fi
#Modify the PHP.ini file
echo "==================Modify the PHP.ini file !!! ========================"
cat >> /opt/server/php/lib/php.ini << EOF
extension=pdo_mysql.so
;extension=pdo.so
;extension=xhprof.so
zend_extension=opcache.so
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=300
opcache.fast_shutdown=1
opcache.enable_cli=1
EOF
G=`echo $?`
if [ $G == 0 ];then
:
else
echo "============The PHP file php.ini error exit !!!=============="
exit 1
fi
/opt/server/php/sbin/php-fpm -t
H=`echo $?`
if [ $H == 0 ];then
:
else
echo "============PHP has syntax errors, please check !!!=============="
exit 1
fi
#Start the PHP-FPM
echo "=============Start the PHP-FPM...==============="
/etc/init.d/php-fpm start
netstat -ntpl
}
mysql_install(){
#Install cmake
echo "===========================Install cmake openssl ncurses ...====================="
yum -y install cmake openssl openssl-devel ncurses-devel gcc gcc-c++
#Create a mysql user
echo "========================Create a mysql user...==================="
groupadd mysql
useradd -g mysql mysql
cd /root/package/
mkdir /opt/server/mysql/data -p
#Mysql installation
echo "======================Mysql installation...====================="
#wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.14.tar.gz
tar fxz mysql-5.6.14.tar.gz
cd mysql-5.6.14
cmake . -DCMAKE_INSTALL_PREFIX=/opt/server/mysql \
-DMYSQL_DATADIR=/opt/server/mysql/data \
-DINSTALL_PLUGINDIR=plugin \
-DINSTALL_SHAREDIR=share \
-DINSTALL_LIBDIR=lib64 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DMYSQL_UNIX_ADDR=/opt/server/mysql/mysqld.sock \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_DEBUG=OFF \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_PROFILING=0
make
make install
A=`echo $?`
if [ $A == 0 ];then
echo "=================== Mysql installation is successful !!! ======================"
cd ..
else
echo "=================== Mysql installation failure !!! ======================="
exit 1
fi
chown -R mysql.mysql /opt/server/mysql
#/bin/cp /opt/server/mysql/support-files/my-default.cnf /etc/my.cnf
rm -fr /etc/my.cnf
rm -fr /opt/server/mysql/my.cnf
cat >> /etc/my.cnf << EOF
[client]
port = 3306
socket = /opt/server/mysql/mysqld.sock
[mysqld]
port = 3306
socket = /opt/server/mysql/mysqld.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 100M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 1024K
read_rnd_buffer_size = 5120K
myisam_sort_buffer_size = 8M
slow_query_log = 1
#log=/tmp/mysqlquery.log
slow_query_log_file=/opt/server/mysql/logs/mysql_slow.log
long-query-time=1
log-bin=mysql-bin
server-id = 1
sql_mode = 0
[mysqldump]
quick
#max_allowed_packet = 16M
#wait_timeout=28800
#interactive_timeout = 2880000
max_allowed_packet = 100M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
EOF
#To initialize the database
cd /opt/server/mysql
./scripts/mysql_install_db --user=mysql --basedir=/opt/server/mysql/
B=`echo $?`
if [ $B == 0 ];then
echo "=================== To initialize the database successfully !!! =================="
else
echo "==================== Database initialization failed !!! ================"
exit 1
fi
mv /opt/server/mysql/my.cnf /opt/server/mysql/my.cnf_bak
#Mysql added to the system service
echo "===================== Mysql added to the system service...=============="
cp /opt/server/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 235 mysql on
#Start the mysql
echo "==================Start the mysql...========================"
/etc/init.d/mysql start
netstat -ntpl
}
case $1 in
nginx) nginx_install
;;
php) php_install
;;
mysql) mysql_install
;;
all)
nginx_install
php_install
mysql_install
;;
*) echo "Usage: `dirname $0`/`basename $0` [nginx|php|mysql|all]"
;;
esac
常用脚本lnmp的更多相关文章
- MS SQL 日常维护管理常用脚本(二)
监控数据库运行 下面是整理.收集监控数据库运行的一些常用脚本,也是MS SQL 日常维护管理常用脚本(一)的续集,欢迎大家补充.提意见. 查看数据库登录名信息 Code Snippet SELEC ...
- Inno Setup的常用脚本
Inno Setup的常用脚本 分类: VC++神奇理论 2012-12-06 10:07 3234人阅读 评论(2) 收藏 举报 安装不同的目录: [Files] Source: "我的程 ...
- 常用脚本语言Perl,Python,Ruby,Javascript一 Perl,Python,Ruby,Javascript
常用脚本语言Perl,Python,Ruby,Javascript一 Perl,Python,Ruby,Javascript Javascript现阶段还不适合用来做独立开发,它的天下还是在web应用 ...
- shell常用脚本
shell常用脚本 author:headsen chen 2017-10-17 15:36:17 个人原创,转载请注明,否则依法追究法律责任 1,vim name.grep.sh 2,cat ...
- Google常用脚本
1.Tampermonkey 可下载常用脚本:https://greasyfork.org/zh-CN 2.常用FQSetupVPN 3.百度药丸屏蔽广告 4.百度文档可粘贴,下载 5.VIP视频可看
- 游戏编程之Unity常用脚本类的继承关系
前言学习Unity开发引擎的初学者会接触大量的脚本类,而这些类之间的关系往往容易被忽略.本文对Unity引擎开发中的一些常用类及其关系进行了简单的归纳总结. 博文首发地址:http://tieba.b ...
- Linux 常用脚本
Linux 常用脚本 修改表列属性 sql可任意修改,若数据库正好在执行机器上,可去掉ip地址 echo 为输出 #!/bin/shfor((i=0;i<256;i++));do ...
- oracle 常用脚本以及语句
oracle 常用脚本以及语句 一.oracle 安装10G 单机初始化环境: #!/bin/bash #关闭selinuxsed -i 's\SELINUX=enforcing\SELINUX=di ...
- PowerDesigner 设计数据库中常用脚本
PowerDesigner 设计数据库中常用脚本 数据库设计 物理模型设置 Name转Comment脚本 '********************************************** ...
随机推荐
- 最全最详细:ubuntu16.04下linux内核编译以及设备驱动程序的编写(针对新手而写)
写在前面:本博客为本人原创,严禁任何形式的转载!本博客只允许放在博客园(.cnblogs.com),如果您在其他网站看到这篇博文,请通过下面这个唯一的合法链接转到原文! 本博客全网唯一合法URL:ht ...
- ORACLE DIRECTORY目录管理步骤
ORACLE DIRECTORY目录管理步骤 ORACLE的 DIRECTORY在数据库中是个目录的路径,需要在操作系统中有相应的目录与之对应:ORACLE目录的作用就是让ORACLE数据库和操作系统 ...
- LeetCode 700 Search in a Binary Search Tree 解题报告
题目要求 Given the root node of a binary search tree (BST) and a value. You need to find the node in the ...
- storm配置文件
- python接口测试实例--数据驱动(程序与数据分离)
#encoding=utf-8import requestsimport jsonimport osimport hashlibimport picklefrom conf import * stat ...
- java开发中乱码的解决
总结一下,在JavaWeb中针对各种情况处理中文乱码的方法. 首先我们看下,一个请求响应的流程 浏览器------------------>Servlet容器---------------> ...
- JavaWeb学习总结——文件上传和下载
在Web应用系统开发中,文件上传和下载功能是非常常用的功能,今天来讲一下JavaWeb中的文件上传和下载功能的实现. 对于文件上传,浏览器在上传的过程中是将文件以流的形式提交到服务器端的,如果直接使用 ...
- oracle中并行执行不一定比串行执行快
并行执行与串行执行相比,能否缩短执行时间,取决于如下几个方面:1.待执行的目标SQL是否适合并行执行,有些SQL是不太适合并行执行的,比如走索引的嵌套循环连接.2.数据库服务器上的硬件资源(如CPU. ...
- Eclipse EE下载安装与配置
Eclipse EE下载安装与配置 一.下载 下载链接:http://www.eclipse.org/downloads/eclipse-packages/ 1.进入Eclipse官网进行下载选择Ec ...
- 前端 HTML body标签相关内容 常用标签 表单标签 form 表单控件分类
表单控件分类 input标签: input标签 type属性的text,password,button按钮,submit按钮 input标签placeholder属性 标签上显示内容 input标签 ...