4132w 发表于 2016-3-1 09:01:03

CentOS 6.5搭建 LNMP 生产环境

CentOS 6.5搭建 LNMP 生产环境

安装前准备:
1、软件包下载:

MySQL5.6.5-M8http://downloads.mysql.com/archives/get/file/mysql-5.6.5-m8.tar.gz
Cmake-2.8.8http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
php-5.4.29http://cn2.php.net.get/php-5.4.29.tar.gz/from/this/mirror
libiconv-1.14http://ftp.gun.org/gnu/libiconv/libiconv-1.14.tar.gz
nginx-1.2.9http://nginx.org/downlload/nginx-1.2.9.tar.gz

2、安装MySQL数据库:因为MySQL从5.5版本开始,不再使用开源软件通行使用的./configure脚本来配置编译选项,而改用cmake命令来编译,而且cmake默认不安装在系统中,所以,我们首先安装cmake软件包:

   a、Cmake安装

1
2
3
4
5
# tar -zxvf cmake-2.8.8.tar.gz
# cd cmake-2.8.8
# ./bootstrap
# gmake
# gmake install





3、安装MySQL


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# tar -zxvf mysql-5.6.5-m8.tar.gz
# cd mysql-5.6.5-m8
# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=UTF8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_INNODB_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306

# make                         #编辑
# make install                        #安装
# useradd -s /sbin/nologin mysql    #添加mysql用户
# cp support-files/my-large.cnf /etc/my.cnf    #复制配置文件
# cd /usr/local/server/mysql
# mkdir -p /data/mysql/data            #创建mysql数据目录
# scripts/mysql_install_db --datadir=/data/mysql/data \   
--defaults-file=/etc/my.cnf --user=mysql                  #初始化数据库
# cp support-files/mysql.server /etc/init.d/    #复制启动脚本
# chkconfig --add mysql.server            #添加启动服务
# service mysql.server start               
# echo "PATH=/opt/mysql/bin">>/etc/profile    #设置环境变量
# echo "export PATH">>/etc/profile





4、安装PHP

    在安装PHP之前,需要安装libconv软件包,其它PHP所需软件包在前面都已经使用yum安装完成了,所以无需重复安装。

    a、安装libiconv软件包


1
2
3
4
5
# tar -zxvf libiconv-1.14.tar.gz
# cd libiconv-1.14
# ./configure --prefix=/usr/local
# make && make install
# ldconfig            #执行ldconfig命令更新动态库缓存




    b、安装PHP


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# tar -zxvf php-5.4.5.tar.gz
# cd php-5.4.5
# ./configure --prefix=/opt/php --disable-debug --disable-ipv6 \
--disable-rpath --enable-bcmath --enable-exif --enable-gd-native-ttf \
--enable-mbregex --enable-mbstring=all --enables-pcntl --enable-sage-mode \
--enable-shmop --enable-soap --enable-sockets --enable-xml \
--with-config-file-path=/opt/php/etc --with-curl --with-curlwrappers \
--with-freetype-dir --with\-gd --with-gettext --with-iconv-dir=/usr/local \
--with-jpeg-dir --with-ldap --with-ldap-sasl --with-libdir=lib \
--with-libxml-dir=/usr --with-mcrypt --with-mhash --with-openssl --with-pdo-mysql \
--with-pear --with-png-dir --with-xmlrpc --with-zlib-dir \
--with-mysqlli=/opt/mysql/bin/mysql_config --with-mysql=/opt/mysql \
--enable-fastcgi --enable-fpm --enable-force-cgi-redirect
#make ZEND_EXTRA_LIBS='-liconv'
# make install
# cp php.ini-production /opt/php/etc/php.ini
# cp /op/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf
#




   5、安装Nginx


1
2
3
4
5
6
7
# tar -zxvf nginx-1.2.9.tar.gz
# cd nginx-1.2.9
# ./configure --prefix=/opt/nginx --user=nobody --group=nobody \
--with-poll_module --with-http_ssl_module --with-http_sub_module \
--with-http_perl_module --with-mail --with-pcre
# make
# make install





   6、启动服务


1
2
3
4
# /opt/php/sbin/php-fpm
# killall -php-fpm
# /opt/nginx/sbin/nginx
# /opt/nginx/sbin/nginx -s stop






页: [1]
查看完整版本: CentOS 6.5搭建 LNMP 生产环境