CentOS 6.5搭建 LNMP 生产环境
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 6.5搭建 LNMP 生产环境相关的知识,希望对你有一定的参考价值。
CentOS 6.5搭建 LNMP 生产环境
安装前准备:
1、软件包下载:
mysql5.6.5-M8 | http://downloads.mysql.com/archives/get/file/mysql-5.6.5-m8.tar.gz |
Cmake-2.8.8 | http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz |
php-5.4.29 | http://cn2.php.net.get/php-5.4.29.tar.gz/from/this/mirror |
libiconv-1.14 | http://ftp.gun.org/gnu/libiconv/libiconv-1.14.tar.gz |
nginx-1.2.9 | http://nginx.org/downlload/nginx-1.2.9.tar.gz |
2、安装MySQL数据库:因为MySQL从5.5版本开始,不再使用开源软件通行使用的./configure脚本来配置编译选项,而改用cmake命令来编译,而且cmake默认不安装在系统中,所以,我们首先安装cmake软件包:
a、Cmake安装
[[email protected]_Server ~]# tar -zxvf cmake-2.8.8.tar.gz [[email protected]_Server ~]# cd cmake-2.8.8 [[email protected]_Server ~]# ./bootstrap [[email protected]_Server ~]# gmake [[email protected]_Server ~]# gmake install
3、安装MySQL
[[email protected]_Server ~]# tar -zxvf mysql-5.6.5-m8.tar.gz [[email protected]_Server ~]# cd mysql-5.6.5-m8 [[email protected]_Server ~]# 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 [[email protected]_Server ~]# make #编辑 [[email protected]_Server ~]# make install #安装 [[email protected]_Server ~]# useradd -s /sbin/nologin mysql #添加mysql用户 [[email protected]_Server ~]# cp support-files/my-large.cnf /etc/my.cnf #复制配置文件 [[email protected]_Server ~]# cd /usr/local/server/mysql [[email protected]_Server ~]# mkdir -p /data/mysql/data #创建mysql数据目录 [[email protected]_Server ~]# scripts/mysql_install_db --datadir=/data/mysql/data \ --defaults-file=/etc/my.cnf --user=mysql #初始化数据库 [[email protected]_Server ~]# cp support-files/mysql.server /etc/init.d/ #复制启动脚本 [[email protected]_Server ~]# chkconfig --add mysql.server #添加启动服务 [[email protected]_Server ~]# service mysql.server start [[email protected]_Server ~]# echo "PATH=/opt/mysql/bin">>/etc/profile #设置环境变量 [[email protected]_Server ~]# echo "export PATH">>/etc/profile
4、安装PHP
在安装PHP之前,需要安装libconv软件包,其它PHP所需软件包在前面都已经使用yum安装完成了,所以无需重复安装。
a、安装libiconv软件包
[[email protected]_Server ~]# tar -zxvf libiconv-1.14.tar.gz [[email protected]_Server ~]# cd libiconv-1.14 [[email protected]_Server ~]# ./configure --prefix=/usr/local [[email protected]_Server ~]# make && make install [[email protected]_Server ~]# ldconfig #执行ldconfig命令更新动态库缓存
b、安装PHP
[[email protected]_Server ~]# tar -zxvf php-5.4.5.tar.gz [[email protected]_Server ~]# cd php-5.4.5 [[email protected]_Server ~]# ./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 [[email protected]_Server ~]# make ZEND_EXTRA_LIBS=‘-liconv‘ [[email protected]_Server ~]# make install [[email protected]_Server ~]# cp php.ini-production /opt/php/etc/php.ini [[email protected]_Server ~]# cp /op/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf [[email protected]_Server ~]#
5、安装Nginx
[[email protected]_Server ~]# tar -zxvf nginx-1.2.9.tar.gz [[email protected]_Server ~]# cd nginx-1.2.9 [[email protected]_Server ~]# ./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 [[email protected]_Server ~]# make [[email protected]_Server ~]# make install
6、启动服务
[[email protected]_Server ~]# /opt/php/sbin/php-fpm [[email protected]_Server ~]# killall -php-fpm [[email protected]_Server ~]# /opt/nginx/sbin/nginx [[email protected]_Server ~]# /opt/nginx/sbin/nginx -s stop
本文出自 “Elephant” 博客,请务必保留此出处http://zlyang.blog.51cto.com/1196234/1745996
以上是关于CentOS 6.5搭建 LNMP 生产环境的主要内容,如果未能解决你的问题,请参考以下文章