LNMP源码安装脚本
LNMP安装脚本,脚本环境 #LNMP环境搭建centos6.8 2.6.32-696.28.1.el6.x86_64 nginx:1.12.2 mysql:5.6.36 PHP:5.5.36
#!/bin/bash
#LNMP环境搭建centos6.8 2.6.32-696.28.1.el6.x86_64 nginx:1.12.2 mysql:5.6.36 PHP:5.5.36
trap 'echo "error line: $LINENO,error cmd: $BASH_COMMAND"' ERR
. /etc/init.d/functions
cd /usr/local/src
[ `rpm -qa wget | wc -l` -ne 1 ] && yum -y install wget
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
cp /usr/local/src/CentOS6-Base-163.repo ./CentOS-Base.repo
yum clean all #清除yum缓存
yum makecache #重建缓存
yum -y update
cd /usr/local/src
#添加epel外部扩展源
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
#安装依赖包:
yum -y install gcc gcc-c++ glibc gcc libtool cmake mcrypt libmcrypt-devel mhash mhash-devel libxslt-devel \
libjpeg libjpeg-devel libjpeg-turbo-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel gd-devel ncurses ncurses-devel curl \
libcurl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel pcre-devel openssh-clients
#进入到src目录下载nginx
cd /usr/local/src && wget http://nginx.org/download/nginx-1.12.2.tar.gz
#创建用户
useradd -M -s /sbin/nologin www
##安装nginx-1.12.2
tar xf nginx-1.12.2.tar.gz && cd nginx-1.12.2
./configure --user=www --group=www \
--prefix=/usr/local/nginx-1.12.2 \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--pid-path=/usr/local/nginx/nginx.pid
#编译并安装
make && make install
RETVAL_Nginx=$?
#创建软连接
ln -s /usr/local/nginx-1.12.2 /usr/local/nginx
##安装mysql
#现在mysql并解压
cd /usr/local/src && wget -c http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36.tar.gz && tar xf mysql-5.6.36.tar.gz
#添加mysql用户
useradd -s /sbin/nologin -M mysql
cd /usr/local/src/mysql-5.6.36
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1
make && make install
RETVAL_Mysql=$?
#配置权限
chown -R root.mysql /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql/data
#–basedir软件安装目录 –datadir数据存放目录 –user管理mysql的用户
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#将mysql服务加入开机自启动
chkconfig --add mysqld && chkconfig mysqld on
#将mysql命令添加环境变量中
echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
source /etc/profile
#拷贝mysql配置文件
\cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
##安装PHP
#安装libiconv 说明:此软件在centos6.8之后已经自带此软件功能,可以不进行安装
cd /usr/local/src && wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz && cd libiconv-1.14
./configure --prefix=/usr/local/libiconv && make && make install
#下载PHP
cd /usr/local/src && wget http://mirrors.sohu.com/php/php-5.5.36.tar.gz
tar xf php-5.5.36.tar.gz && cd php-5.5.36
#配置PHP(如果本地没有安装mysql 可以使用PHP自带的扩展--with-mysql=mysqlnd)
./configure \
--prefix=/usr/local/php-5.5.36 \
--with-config-file-path=/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-pcre-regex \
--with-zlib \
--with-libxml-dir=/usr \
--with-curl \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-soap \
--enable-short-tags \
--enable-shmop \
--enable-static \
--enable-ftp \
--enable-opcache=no \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-zip \
--enable-inline-optimization \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets
#防止报错/usr/local/src/php-5.5.36/sapi/cli/php: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
touch ext/phar/phar.phar
make && make install
RETVAL_Php=$?
ln -sf /usr/local/php-5.5.36 /usr/local/php
cp php.ini-production /usr/local/php-5.5.36/etc/php.ini
cd /usr/local/php-5.5.36/etc/ && cp php-fpm.conf.default php-fpm.conf
cp /usr/local/src/php-5.5.36/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && chmod +x /etc/init.d/php-fpm
#配置脚本读取指定php配置文件
sed -i 's#php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"#php_opts="--fpm-config $php_fpm_CONF -c /usr/local/php/etc/php.ini --pid $php_fpm_PID"#g' /etc/init.d/php-fpm
echo -e "/etc/init.d/php-fpm start\n/usr/local/sbin/nginx\n/etc/init.d/mysqld start" >> /etc/rc.local
if [ -d /usr/local/nginx-1.12.2 -a "$RETVAL_Nginx" -eq "0" ];then
action "Installed Nginx" /bin/true
echo -e "Use \e[1;32m/usr/local/sbin/nginx\e[0m to start nginx"
else
action "Install Nginx" /bin/false
fi
if [ -d /usr/local/mysql -a "$RETVAL_Mysql" -eq "0" ];then
action "Installed Mysql" /bin/true
echo -e "Use \e[1;32m/etc/init.d/mysqld\e[0m start to start mysql"
else
action "Install Mysql" /bin/false
fi
if [ -d /usr/local/php-5.5.36 -a "$RETVAL_Php" -eq "0" ];then
action "Installed PHP" /bin/true
echo -e "Use \e[1;32m/etc/init.d/php-fpm start\e[0m to start php-fpm"
else
action "Install PHP" /bin/false
fi
LNMP源码安装脚本的更多相关文章
- 部署 LNMP(源码安装版本)shell脚本
#!/bin/bash # 一键部署 LNMP(源码安装版本) menu() { clear echo " ##############‐‐‐‐Menu‐‐‐‐##############& ...
- LNMP 源码安装
参考文档:http://essun.blog.51cto.com/721033/1288442 安装的时候提示要安装zlib库 yum -y install zlib zlib-devel 源码安装P ...
- lnmp源码安装以及简单配置
nginx 软件: a: openssl-1.0.1r.tar.gz tar zxf openssl-1.0.1r.tar.gz b: pcre-8.32.tar.gz tar zxf openssl ...
- LNMP最新源码安装脚本(定期更新)
Linux+Nginx+MySQL+PHP+Pureftpd+User manager for PureFTPd,脚本中用到的软件包大多最新版本,修复了User manager for PureFTP ...
- LNMP源码安装
1. mysql安装 # Preconfiguration setup shell > groupadd mysql shell > useradd -r -g mysql -s /bin ...
- Openresty 源码安装脚本
Openresty 中文官网地址 http://openresty.org/cn/ #! /bin/bash function openrestyinstall() { cd /opt/openres ...
- CentOS6源码安装zabbix服务器
1.下载安装包并解压 2.预环境搭建 3.创建zabbix用户,编译安装zabbix 4.配置mysql 5.配置zabbix-server 6.配置apache和php 7.添加开机自启动 1 yu ...
- 在ConoHa上Centos7环境下源码安装部署LNMP
本文记录了从源码,在Centos 7上手动部署LNMP环境的过程,为了方便以后对nginx和mariadb进行升级,这里采用yum的方式进行安装. 1.建立运行网站和数据库的用户和组 groupadd ...
- LNMP架构下的nginx、mysql、php的源码安装
一.LNMP的介绍 LNMP就是Linux+Nginx+Mysql+Php这种网站服务架构.Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统,常见版本有:centos.ubun ...
随机推荐
- LeetCode 260 Single Number III 数组中除了两个数外,其他的数都出现了两次,找出这两个只出现一次的数
Given an array of numbers nums, in which exactly two elements appear only once and all the other ele ...
- C# 枚举与switch用法
using System; namespace Csharp { class Program { //枚举 public enum TimeOfDay { Morning=, Afternoon=, ...
- JDK动态代理详解-依赖接口
0. 原理分析 a). 自定义实现InvocationHandler类,实现代理类执行时的invoke方法 b). 使用Proxy.newProxyInstance生成接口的代理类(入参还包括Invo ...
- Comparing Two High-Performance I/O Design Patterns--reference
by Alexander Libman with Vladimir GilbourdNovember 25, 2005 Summary This article investigates and co ...
- 将MySQL转化为mysqli
<?php/** * Created by PhpStorm. * User: 大神 * Date: 2017/7/24 * Time: 11:29 */ header('content-typ ...
- Asp.net中的ViewState用法
Session,ViewState用法基本理论:session值是保存在服务器内存上,那么,可以肯定,大量的使用session将导致服务器负担加重. 而viewstate由于只是将数据存入到页面隐藏控 ...
- ssm(Spring、Springmvc、Mybatis)实战之淘淘商城-第十二天(非原创)
文章大纲 一.课程介绍二.Ngnix基础知识学习三.Ngnix在淘淘商城中使用四.参考资料下载五.参考文章 一.课程介绍 一共14天课程(1)第一天:电商行业的背景.淘淘商城的介绍.搭建项目工程.Sv ...
- java-类的定义和用法
1.类的定义 public class Human{ }//每个源文件必须也只能有一个public类 class boy{ }//可以定义多个class类 class girl{ } 上面的类定义好后 ...
- Java基础反射-调用类
Student类 package com.test.wang; import java.lang.reflect.Constructor; import java.lang.reflect.Field ...
- ABAP ICON
1.输出图标的3种方法 WRITE: / '@09@'. "id WRITE: / icon_yellow_light. "name WRITE: / '@S_TL_Y@'. &q ...