码迷,mamicode.com
首页 > Web开发 > 详细

nginx1.8.0和php7.0.4编译安装脚本

时间:2016-04-29 01:54:35      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:nginx1.8.0和php7.0.4编译安装脚本

最近比较忙,原来还想每天都发博文的,不过时间好像不够,最近在安装docker,用于部署公司的测试环境,然后把svn服务器从啊里云迁移回来本地,还有一大堆问题处理,整理了一下脚本,有nginx,php,mysql,redis,nodejs,golang,现在都搞成一键脚本了,不过现在使用docker真的很方便,部署完基础环境后直接打包成容器镜像就行了,下次直接使用一条命令就把环境部署出来,以下是nginx和php的脚本,贴出来和大家分享一下:

nginx_sh脚本:


#!/bin/sh

###############################################################

#this scripts is created by hejp at 2016-3-30 for install nginx

###############################################################


echo "------ step 0: stop iptables and selinux------"

systemctl stop firewalld.service

systemctl disable firewalld.service

setenforce 0

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

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

setenforce 0

fi


echo "------ step 1: centos7 install pcre and openssl ------"

yum install pcre pcre-devel -y

yum install openssl openssl-devel -y

useradd -s /sbin/nologin -M nginx


echo "------ step 2: config nginx ------"

tar zxvf nginx-1.8.0.tar.gz 

cd nginx-1.8.0


./configure --user=nginx --group=nginx --prefix=/application/nginx1.8.0 --with-http_stub_status_module --with-http_ssl_module 

make

make install

ln -s /application/nginx1.8.0/ /application/nginx

ll /application/nginx


echo "------ step 3: start nginx and check ------"

/application/nginx/sbin/nginx -t 

/application/nginx/sbin/nginx

echo -----------

lsof -i tcp:80

echo ----------

ps -ef|grep nginx

echo "NGINX is successfully installed."

echo "ok"

###########   end   ############################################################



php_sh脚本:


#!/bin/sh

###

###this scripts is created by hejp at 2016-3-31 for php server

###


echo "------ step 0: centos7 php7.0.4 download dependencies ------"

cd /home/hejp/tools/

tar zxvf php-7.0.4.tar.gz 

cd php-7.0.4

 yum install libxslt* -y



echo "------ step 1: centos7 php7.0.4 make  ------"

./configure \

--prefix=/application/php7.0.4 \

--with-config-file-path=/application/php7.0.4/etc \

--with-config-file-scan-dir=/application/php7.0.4/etc/php.d \

--with-mysql-sock=/application/mysql-5.6.17/tmp/mysql.sock \

--with-mcrypt=/usr/local \

--enable-mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=/application/mysql-5.6.17 \

--enable-fpm \

--with-fpm-user=nginx \

--with-fpm-group=nginx \

--with-gd \

--with-iconv \

--with-zlib \

--enable-xml \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--enable-mbregex \

--enable-mbstring \

--enable-ftp \

--enable-gd-native-ttf \

--with-openssl \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--without-pear \

--with-gettext \

--enable-session \

--with-curl \

--with-jpeg-dir \

--with-freetype-dir \

--enable-opcache


ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/ 

make

make install

ln -s /application/php7.0.5/ /application/php


echo "------ step 2: centos7 php7.0.4 php.ini php-fpm.conf  ------"

#从安装目录拷贝配置文件。

cp php.ini-production /application/php/lib/php.ini

cd /application/php/etc/

cp php-fpm.conf.default php-fpm.conf

[ -f php-fpm.conf ] &&\

sed -i "s%;pid = run/php-fpm.pid%pid = /app/logs/php-fpm.pid%g" php-fpm.conf

sed -i "s%;error_log = log/php-fpm.log%error_log = /app/logs/php-fpm.log%g" php-fpm.conf

sed -i "s%;log_level = notice%log_level = error%g" php-fpm.conf

sed -i "s%;rlimit_files = 1024%rlimit_files = 32768%g" php-fpm.conf

sed -i "s%; events.mechanism = epoll%events.mechanism = epoll%g" php-fpm.conf

sed -i "s%;rlimit_files = 1024%rlimit_files = 32768%g" php-fpm.conf


cd /application/php/etc/php-fpm.d/

cp www.conf.default www.conf

[ -f www.conf ] &&\

sed -i "s/;listen.owner = nginx/listen.owner = nginx/g"  www.conf

sed -i "s/;listen.group = nginx/listen.group = nginx/g"  www.conf

sed -i "s/;listen.mode = 0660/listen.mode = 0660/g"  www.conf

sed -i "s/pm.max_children = 5/pm.max_children = 1024/g"  www.conf

sed -i "s/pm.start_servers = 2/pm.start_servers = 16/g"  www.conf

sed -i "s/pm.min_spare_servers = 1/pm.min_spare_servers = 5/g"  www.conf

sed -i "s/pm.max_spare_servers = 3/pm.max_spare_servers = 20/g"  www.conf

sed -i "s/;pm.process_idle_timeout = 10s;/pm.process_idle_timeout = 15s;/g"  www.conf

sed -i "s/;pm.max_requests = 500/pm.max_requests = 2048/g"  www.conf



mkdir /app/logs -p

/application/php/sbin/php-fpm -t

/application/php/sbin/php-fpm 

netstat -lntup|grep php-fpm

ps -ef|grep php-fpm

echo "ok!"

##################### end #########################################################

本文出自 “早起的鸟儿有虫吃” 博客,谢绝转载!

nginx1.8.0和php7.0.4编译安装脚本

标签:nginx1.8.0和php7.0.4编译安装脚本

原文地址:http://hejianping.blog.51cto.com/11279690/1768820

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