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 ...
随机推荐
- 如何 求Ifeature 的面积
IArea pArea = pfteature_Source.Shape as IArea;// IArea来自geometry double dArea = Math.Round(pArea.Ar ...
- 《疯狂动物城》主题曲《TryEverything》中文翻译
<疯狂动物城>主题曲<TryEverything>夏奇拉激情献唱,很多事情是需要是试试,不试试就不知道可以成功. Oh oh oh oh oooh 哦哦哦哦哦 Oh oh oh ...
- spring boot整合redis,以及设置缓存过期时间
spring-boot 整合 redis 注:redis服务器要先开启 pom文件: <dependency> <groupId>org.springframework.boo ...
- Mavlink 协议 理解
来源:blog.csdn.net/super_mice/article/details/44836585 之前看了mavlink协议,网上关于mavlink的资料不多.本文大概总结了下对mavlink ...
- WPF动画的几种模式
最近在用WPF做简单动画,以下是几点经验总结: 1. 使用DispatcherTimer做动画 VB6的年代大家就用Timer做动画了,不用多解释,这个DispatcherTimer和本身的Timer ...
- [WPF][ListBox]鼠标拖拽多选,(Shift Key、Ctrl Key多选有效)(转)
<ListBox Name="listBox" SelectionMode="Extended"> <ListBox.Resources> ...
- 【Android开发笔记】程序崩溃异常总结
广播注册相关(broadcastReceiver) 没有注册广播就注销广播 注册广播但未注销广播 注册广播后重复注销广播 解决办法: 添加一个布尔变量,注册广播后为true,若为true在执行注销,注 ...
- Python3基础12(collections、struct、itertools、chardet等的使用)
import struct import base64import itertoolsimport chardet from collections import namedtuple,default ...
- javascript的Array.prototype.map()和jQuery的jQuery.map()
两个方法都可以根据现有数组创建新数组,但在使用过程中发现有些不同之处 以下面这个数据为例: var numbers = [1, 3, 4, 6, 9]; 1. 对undefined和null的处理 a ...
- 数据字典的设计--3.首页添加删除表格(JS实现)
页面效果: JS代码: 1.添加表格 function insertRows(){ //获取表格对象 var tb1 = $("#dictTbl"); var tempRow = ...