Centos6.4 安装配置LNMP

配置环境:

L:Centos 2.6.32-358.el6.x86_64

N:Nginx 1.7

M:Mysql5.7.3

P:PHP5.5.11

NGINX一键脚本:

#!/bin/bash

# Author:Byrd

# Version:1.0

# Site:www.t4x.org

# Contact:root#t4x.org

# Compile and install NGINX BY:BYRD AT:2014-04-30

# This script for nginx1.4 nginx1.6 nginx1.7

# Define

DownTools=/byrd/tools

NginxWget=http://nginx.org/download/nginx-1.7.4.tar.gz

Openssl=http://www.openssl.org/source/openssl-1.0.1h.tar.gz

NginxVersion=nginx-1.7.4

InstallNginxDir=/byrd/service

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

LANG="en_US.UTF-8"

# Check if user is root

if [ $UID != "0" ]; then

echo "Error: You must be root to run this script, please use root to install lnmp"

exit 1

fi

clear

echo "========================================================================="

echo "============================Install Nginx================================"

echo "========================================================================="

echo "=============================www.t4x.org================================="

echo "========================================================================="

# Create web user

groupadd www

useradd -s /sbin/nologin -g www www

yum install pcre* openssl* openssl-devel gcc gcc-c++ wget vim -y

# Create a file download directory

[ ! -d $DownTools ] && mkdir -p $DownTools

[ ! -d $InstallNginxDir ] && mkdir $InstallNginxDir

cd $InstallNginxDir

if [ ! -f openssl-1.0.1h.tar.gz ];then

wget $Openssl || exit 1  && echo "Please changes Openssl URL"

tar zxf openssl-1.0.1h.tar.gz

cd openssl-1.0.1h

./config

make

else

tar zxf openssl-1.0.1h.tar.gz

cd openssl-1.0.1h

./config

make

fi

RETVAL1=$?

if [ $RETVAL1 -eq 0 ];then

echo "Openssl installed successfully"

else

exit $RETVAL1

fi

cd $DownTools

wget $NginxWget

tar zxf $NginxVersion.tar.gz

cd $NginxVersion

./configure --user=www --group=www --prefix=$InstallNginxDir/$NginxVersion --with-openssl=$InstallNginxDir/openssl-1.0.1h --with-pcre --with-http_ssl_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module
 --with-ipv6 --with-http_sub_module &&

#./configure --user=www --group=www --prefix=/byrd/service/nginx-1.6.2 --with-openssl=/byrd/service/openssl-1.0.1j --with-pcre --with-http_ssl_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module
--with-http_sub_module

make && make install

RETVAL2=$?

if [ $RETVAL2 -eq 0 ];then

echo "Nginx installed successfully"

else

exit $RETVAL2

fi

ln -s $InstallNginxDir/$NginxVersion /usr/local/nginx

/usr/local/nginx/sbin/nginx

/bin/netstat -tunlp | /bin/grep 80

if [ -s /sbin/iptables ]; then

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT

/sbin/iptables-save

fi

Mysql一键安装:

#!/bin/bash

# Author:Byrd

# Version:1.0

# Site:www.t4x.org

# Contact:root#t4x.org

# This script for Mysql 5.6.16

# Check if user is root

if [ $UID != "0" ]; then

echo "Error: You must be root to run this script, please use root to install lnmp"

exit 1

fi

clear

echo "========================================================================="

echo "Will automatically install mysql"

echo "========================================================================="

MysqlInstall=/byrd/service

DownMysqlTools=/byrd/tools

MysqlUrl=http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.19.tar.gz

Version=mysql-5.6.19

[ ! -d $DownMysqlTools ] && mkdir -p $DownMysqlTools

[ ! -d $MysqlInstall ] && mkdir $MysqlInstall

groupadd mysql

useradd -s /sbin/nologin -g mysql mysql

yum install pcre* openssl* openssl-devel gcc gcc-c++ cmake libaio* library* ncurses-* -y

cd $DownMysqlTools

if [ ! -f $Version.tar.gz ];then

wget $MysqlUrl

tar zxf $Version.tar.gz

cd $Version

cmake . -DCMAKE_INSTALL_PREFIX=$MysqlInstall/$Version -DMYSQL_DATADIR=$MysqlInstall/$Version/data -DMYSQL_UNIX_ADDR=$MysqlInstall/$Version/tmp/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 &&

make && make install

RETVAL1=$?

elif [ -f  $Version.tar.gz ];then

tar zxf $Version.tar.gz

cd $Version

cmake . -DCMAKE_INSTALL_PREFIX=$MysqlInstall/$Version -DMYSQL_DATADIR=$MysqlInstall/$Version/data -DMYSQL_UNIX_ADDR=$MysqlInstall/$Version/tmp/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 &&

make && make install

RETVAL1=$?

else

exit 1

fi

if [ $RETVAL1 -eq 0 ];then

echo "$Version install successful"

else

echo "$Version install failed."

fi

ln -s $MysqlInstall/$Version /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql

/bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

/bin/mv /etc/my.cnf /etc/my.cnf.backup

/bin/cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

/etc/init.d/mysqld start

if [ `netstat -tunlp | grep mysql |wc -l` -ne 0 ];then

echo "$Version Starting successful"

else

echo "$Version Starting failed."

fi

PHP一键脚本:

#!/bin/bash

# Author:Byrd

# Version:1.0

# Site:www.t4x.org

# Contact:root#t4x.org

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

LANG="en_US.UTF-8"

# Check if user is root

if [ $UID != "0" ]; then

echo "Error: You must be root to run this script, please use root to install lnmp"

exit 1

fi

clear

echo "========================================================================="

echo            "Install PHP5.5.11 BY:BYRD AT:2014-04-30"

echo "========================================================================="

RETVAL=0

SoftTool=/byrd/tools

Server=/byrd/server

LibiconvUrl=http://ftp.gnu.org/gnu/libiconv/libiconv-1.9.2.tar.gz

LibicoVern=libiconv-1.9.2

[ ! -d $SoftTool ] && mkdir -p $SoftTool

[ ! -d $Server ] && mkdir $Server

yum install zlib libjpeg freetype libpng gd curl zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel gcc gcc-c++ wget libxml* libtool* libxslt* -y

cd $SoftTool

if [ ! -f $LibicoVern.tar.gz ];then

wget $LibiconvUrl || exit 1 && echo "$LibicoVern Download Error,Please try again"

tar zxf $LibicoVern.tar.gz

cd $LibicoVern

./configure --prefix=/usr/local/libiconv

make && make install

RETVAL1=$?

elif [ -f $LibicoVern.tar.gz ];then

tar zxf $LibicoVern.tar.gz

cd $LibicoVern

./configure --prefix=/usr/local/libiconv

make && make install

RETVAL1=$?

else

exit 1

fi

if [ `echo $RETVAL1` -eq $RETVAL ];then

echo "$LibicoVern Install Successful"

else

echo "$LibicoVern Install Failured"

exit `echo $RETVAL1`

fi

libmcryptUrl=http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

libmcryptVen=libmcrypt-2.5.8

cd $SoftTool

if [ ! -f $libmcryptVen.tar.gz ];then

wget $libmcryptUrl || exit 1 && echo "$libmcryptVen.tar.gz Download Error,Please try again"

tar zxf $libmcryptVen.tar.gz

cd $libmcryptVen

./configure

make && make install

RETVAL2=$?

rm -f /usr/lib/libmcrypt.*

rm -f /usr/lib/libmhash*

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

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

rm -f /usr/lib64/libmcrypt.*

rm -f /usr/lib64/libmhash*

ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la

ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so

ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4

ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8

ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a

ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la

ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so

ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2

ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib64/

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

ldconfig -v

elif [ -f $libmcryptVen.tar.gz ];then

tar zxf $libmcryptVen.tar.gz

cd $libmcryptVen

./configure

make && make install

rm -f /usr/lib/libmcrypt.*

rm -f /usr/lib/libmhash*

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

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

rm -f /usr/lib64/libmcrypt.*

rm -f /usr/lib64/libmhash*

ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la

ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so

ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4

ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8

ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a

ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la

ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so

ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2

ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib64/

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

ldconfig -v

else

exit 1

fi

if [ `echo $RETVAL2` -eq $RETVAL ];then

echo "$libmcryptVen Install Successful"

else

echo "$libmcryptVen Install Failured"

exit `echo $RETVAL2`

fi

cd $SoftTool

mhashUrl=http://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz

mhashDev=mhash-0.9.9.9

if [ ! -f $mhashDev.tar.gz ];then

wget $mhashUrl

tar zxf $mhashDev.tar.gz

cd $mhashDev

./configure

make && make install

RETVAL3=$?

else

tar zxf $mhashDev.tar.gz

cd $mhashDev

./configure

make && make install

RETVAL3=$?

fi

if [ `echo $RETVAL3` -eq $RETVAL ];then

echo "$mhashDev Install Successful"

else

echo "$mhashDev Install Failured"

exit `echo $RETVAL3`

fi

cd $SoftTool

PhpUrl=http://am1.php.net/distributions/php-5.5.11.tar.gz

PhpVen=php-5.5.11

if [ ! -f $PhpVen.tar.gz ];then

wget $PhpUrl

tar zxf $PhpVen.tar.gz

cd $PhpVen

./configure --enable-opcache --prefix=$Server/$PhpVen --with-mysql=/usr/local/mysql/ --with-mysqli --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath
--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap
--enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp

make && make install

RETVAL4=$?

else

tar zxf $PhpVen.tar.gz

cd $PhpVen

./configure --enable-opcache --prefix=$Server/$PhpVen --with-mysql=/usr/local/mysql/ --with-mysqli --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath
--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap
--enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp

make && make install

RETVAL4=$?

fi

if [ `echo $RETVAL4` -eq $RETVAL ];then

echo "$PhpVen Install Successful"

else

echo "$PhpVen Install Failured"

exit `echo $RETVAL4`

fi

ln -s $Server/$PhpVen /usr/local/php

cp $SoftTool/$PhpVen/php.ini-production /usr/local/php/lib/php.ini

mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

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

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

if [ `netstat -tunlp | grep php-fpm |wc -l` -ne 0 ];then

echo "$PhpVen Starting successful"

else

echo "$PhpVen Starting failed."

fi

PHP参数设置:

./configure --enable-opcache --prefix=/Byrd/service/php-5.5.11 --with-mysql=/usr/local/mysql/ --with-mysqli --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath
--enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc
--enable-zip --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=bywww --with-fpm-group=bywww --enable-ftp --disable-fileinfo --with-pdo-mysql

基于Centos6.4 X64、PHP5.5.11、NGINX1.7、MYSQL5.7.3

时间: 2024-10-12 09:59:17

Centos6.4 安装配置LNMP的相关文章

CentOS 6.4 安装配置LNMP服务器(Nginx+PHP+MySQL) 及搭建Wordpress

准备:1.配置防火墙,开启80端口.3306端口 # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state –state ESTABLISHED,RE

CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)

以下全部转载于  http://blog.csdn.net/lane_l/article/details/20235909 本人于今晚按照该文章使用centos 6.7 64bit安装成功,做个备份,就转过来了. --------------------------------------------------------------- 转载者语: 转载于:http://www.osyunwei.com/archives/2353.html 原文标题:CentOS 6.2yum安装配置lnmp

CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)

CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) 一.准备篇: 1 /etc/init.d/iptables stop #关闭防火墙 2 关闭SELINUX 3 vi /etc/selinux/config 4 #SELINUX=enforcing #注释掉 5 #SELINUXTYPE=targeted #注释掉 6 SELINUX=disabled #增加 7 :wq 8 shutdown -r now #重启系统 二.安装篇 1.安装nginx 1 yum re

CentOS-6.5安装配置Tomcat-7

https://my.oschina.net/u/593517/blog/304483 http://blog.csdn.net/lgh0824/article/details/51194116 摘要: CentOS-6.5安装配置Tomcat-7 安装说明 安装环境:CentOS-6.3安装方式:源码安装 软件:apache-tomcat-7.0.29.tar.gz下载地址:http://tomcat.apache.org/download-70.cgi 安装前提 系统必须已经安装配置了JDK

CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)

准备篇 1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙 备注:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败, 正确

centos6.5_x64 安装配置java+tomcat+apache

1.下载: # wget http://download.oracle.com/otn-pub/java/jdk/6u31-b04/jdk-6u31-linux-x64-rpm.bin 2.赋权限: [[email protected] ~]# ls -l jdk-6u31-linux-x64-rpm.bin -rw-r--r-- 1 root root 81071431 Jun 26 14:00 jdk-6u31-linux-x64-rpm.bin [[email protected] ~]#

[转]CentOS-6.3安装配置cmake

CentOS-6.3安装配置cmake zhoulf 2013-02-03 原创 安装说明 安装环境:CentOS-6.3安装方式:源码编译安装 软件:cmake-2.8.10.2.tar.gz下载地址:http://www.cmake.org/cmake/resources/software.html 安装前提 系统中已经安装了g++和ncurses-devel,如果没有安装使用下面的命令安装: [[email protected] /]# yum install gcc-c++[[email

[转]Centos6.5安装配置keepalived

参考博文: Centos6.5安装配置keepalived CentOS6.5 keepalived详解及实现Nginx服务的高可用性 CentOS6.5 LVS + KeepAlived搭建步骤 我采用yum 方式  直接安装  版本为1.2.13 # yum -y install keepalived global_defs { #全局定义 notification_email { #定义邮件提醒 一行一个 多个人写多行 acassen@firewall.loc failover@firew

Chapter one:安装配置LNMP

源码安装配置LNMP 更新时间:2016-08-02 系统环境:CentOS 6.5 软件环境:nginx 1.8.1.mysql 5.6.22.php 5.6.19 本机IP  :192.168.1.88.192.168.1.36 关闭防火墙和安全机制 #service iptables stop #setenforce 0 #getenforce [nginx] 1. 创建用户 #groupadd nginx #useradd -M -s /sbin/nologin nginx -g ngi