服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > 开发教程 > linux教程 >

Centos 6 编译安装LNMP

时间:2016-10-10 09:32来源:未知 作者:最模板编辑 点击:
搭建环境:Centos 6.8,nginx 1.9.14,mysql 5.6.23,php 5.6.17 一、目的:LNMP如今已成为主流的web服务器搭建方案,如公司内部的ECstore,Discuz,计划用来替代nagios+check_mk监控平台的Zabbix。均可以
搭建环境:Centos 6.8,nginx 1.9.14,mysql 5.6.23,php 5.6.17   
 
一、目的:LNMP如今已成为主流的web服务器搭建方案,如公司内部的ECstore,Discuz,计划用来替代nagios+check_mk监控平台的Zabbix。均可以基于LNMP。本次单机LNMP搭建为熟悉电商集群做准备,顺便记录下搭建过程,省的每次搭建完后,下回搭建又得重头再来。
 
二、LNMP安装环境准备:
 
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers make  libtool* git tree bision pcre-devel perl
安装libiconv
 
tar zxvf libiconv-1.14.tar.gz 
cd libiconv-1.14/ 
./configure --prefix=/usr/local 
make && make install
安装libmcrypt
 
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make 
make install 
cd libltdl/ 
./configure --enable-ltdl-install 
make 
make install
安装mhash
 
tar xfmhash-0.9.9.9.tar.bz2 
cd mhash-0.9.9.9
./configure
make&& make install
安装mcript
 
cd /usr/local/src
tar zxvf mcrypt-2.6.8.tar.gz 
cd mcrypt-2.6.8/ 
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH  
./configure 
make 
make install
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
安装cmake
 
tar zxvfcmake-3.4.1.tar.gz
cd cmake-3.4.1
./bootstrap
make && make install
三、MySQL编译安装
 
新增mysql用户
 
groupadd -r mysql
useradd -r -g mysql mysql
新建MySQL所需目录
 
mkdir -p /usr/local/mysql 
mkdir -p /data/mysqldb
编译安装
 
tar zxvf mysql-5.6.23.tar.gzcd mysql-5.6.23
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\ 
-DDEFAULT_CHARSET=utf8\ 
-DDEFAULT_COLLATION=utf8_general_ci\ 
-DWITH_INNOBASE_STORAGE_ENGINE=1\ 
-DWITH_ARCHIVE_STORAGE_ENGINE=1\  
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\ 
-DMYSQL_DATADIR=/data/mysqldb\ 
-DMYSQL_TCP_PORT=3306\ 
-DENABLE_DOWNLOADS=1\ 
-DSYSCONFDIR=/etc\  
-DWITH_SSL=system\ 
-DWITH_ZLIB=system\  
-DWITH_LIBWRAP=0
make&& make install
修改mysql目录权限
 
cd /usr/local/mysql 
chown -R mysql:mysql .
cd /data/mysqldb 
chown -R mysql:mysql .
初始化mysql数据库
 
cd/usr/local/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
编译修改/etc/my.cnf
 
[mysql]
 
# CLIENT #
port                           = 3306
socket                         = /data/mysqldb/mysql.sock
 
[mysqld]
 
# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
socket                         = /data/mysqldb/mysql.sock
pid-file                       = /data/mysqldb/mysql.pid
 
# MyISAM #
key-buffer-size                = 32M
myisam-recover                 = FORCE,BACKUP
 
# SAFETY #
max-allowed-packet             = 16M
max-connect-errors             = 1000000
 
# DATA STORAGE #
datadir                        = /data/mysqldb/
 
# BINARY LOGGING #
log-bin                        = /data/mysqldb/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1
 
# REPLICATION #
skip-slave-start               = 1
relay-log                      = /data/mysqldb/relay-bin
slave-net-timeout              = 60
 
# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 0
max-connections                = 500
thread-cache-size              = 50
open-files-limit               = 65535
table-definition-cache         = 4096
table-open-cache               = 4096
 
# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 64M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 592M
 
# LOGGING #
log-error                      = /data/mysqldb/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /data/mysqldb/mysql-slow.log
复制MySQL启动文件及其命令加入PATH
 
cp support-files/mysql.server /etc/init.d/mysqld   
vim /etc/profile.d/mysql.sh
    PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
    export PATH
source /etc/profile.d/mysql.sh
启动MySQL并增加启动项
 
service mysqld start 
chkconfig  mysqld on
设置MySQL登录权限
 
drop user ''@localhost;
drop user ''@hostname;
update mysql.user set password=password('*******');
flush privileges;
四、Nginx编译安装
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------