CentOS B2C-LNMP 环境搭建

#!/bin/sh

#

#B2C-LNMP 环境搭建

#

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

# 编译安装前的准备工作

yum -y install make gcc-c++ cmake bison-devel ncurses-devel

yum install -y gcc gcc-c++ kernel-devel

yum install -y readline-devel pcre-devel openssl-devel openssl zlib zlib-devel pcre-devel

yum -y install libmcrypt libmcrypt-devel php-mcrypt php-mbstring

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

# 准备所有资源 放到 /usr/local/src 目录下

cd /usr/local/src

# Install Nginx

=============================================================

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz

tar -zxvf pcre-8.33.tar.gz

cd pcre-8.33

./configure

make

make install

wget http://zlib.net/zlib-1.2.8.tar.gz

tar -zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure

make

make install

wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz

tar -zxvf openssl-1.0.1c.tar.gz

cd openssl-1.0.1c

./config

make

make install

wget http://nginx.org/download/nginx-1.9.6.tar.gz

tar -zxvf nginx-1.9.6.tar.gz

cd nginx-1.9.6

./configure --prefix=/usr/local/nginx/ --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.33 --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1c

make

make install

# Install Mysql

=============================================================

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz

tar -zxvf mysql-5.6.22.tar.gz

cd mysql-5.6.22

cmake

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_DATADIR=/usr/local/mysql/data

-DSYSCONFDIR=/etc

-DWITH_MYISAM_STORAGE_ENGINE=1

-DWITH_INNOBASE_STORAGE_ENGINE=1

-DWITH_MEMORY_STORAGE_ENGINE=1

-DWITH_READLINE=1

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock

-DMYSQL_TCP_PORT=3306

-DENABLED_LOCAL_INFILE=1

-DWITH_PARTITION_STORAGE_ENGINE=1

-DEXTRA_CHARSETS=all

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

make && make install

groupadd mysql

useradd -g mysql mysql

mkdir /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql

cp support-files/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

cd /usr/local/mysql

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

rm -rf /etc/my.cnf

chkconfig mysql on

service mysql start

ln -s /usr/local/mysql/bin/mysql /usr/bin/

mysql

grant all privileges on *.* to root@"%" identified by "xxxxxpass";

FLUSH PRIVILEGES;

exit;

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

SET PASSWORD FOR 'root'@'%' = PASSWORD('newpass');

# Install PHP

=============================================================

wget http://cn2.php.net/get/php-5.5.26.tar.gz/from/this/mirror

tar -zxvf php-5.5.26.tar.gz

cd php-5.5.26

./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --enable-pdo --with-curl -disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir --with-gettext --with-openssl --enable-opcache=no

make

make install

cp php.ini-development /usr/local/php/lib/php.ini

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

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

出现如下错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

处理之:

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz

tar -zxvf libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7

./configure

make

make install

出现如下错误:

yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y

yum install libcurl libcurl-devel -y

yum install bzip2 bzip2-devel

yum install libxml2 libxml2-devel -y

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

# Install Redis for PHP Ext

=============================================================

wget http://pecl.php.net/get/redis-2.2.7.tgz

tar xvzf redis-2.2.7.tgz

cd redis-2.2.7

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

vim /usr/local/php/lib/php.ini

extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/redis.so"

# install redis:

=============================================================

http://redis.io/download

wget https://github.com/antirez/redis/archive/2.8.23.tar.gz

tar xzf 2.8.23.tar.gz

cd redis-2.8.23

make

mkdir mkdir -p /usr/local/redis/bin/-p /usr/local/redis/bin/

mkdir -p /usr/local/redis/conf/

cp redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server /usr/local/redis/bin/

cp redis.conf /usr/local/redis/conf/

/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf

/usr/local/redis/bin/redis-cli

chmod +x /usr/local/redis/bin/*

redis> keys *

redis> set key "hello"

OK

redis> get key

"hello"

redis-cli shutdown

posted @ 2018-09-11 11:15  小屁孩2  阅读(106)  评论(0)    收藏  举报