LAMP 全功能编译安装 for CentOS 6.3笔记
最近抽空在虚拟机上测试成功了LAMP各个最新版本的整合编译安装,算是把之前的博文整合精简,以下内容均在CentOS6.3(安装minimal desktop和默认开发包)下测试安装成功,并做了相应优化配置,如有遗漏,还请留言指教.
Linux操作系统:centOS6.3 64bit(安装了系统默认开发包)
APACHE:httpd-2.4.4
MYSQL:mysql-5.6.10
PHP:php-5.4.13
注:推荐安装centos6.3系统时,在系统安装向导中将默认开发包勾上,避免后期编译报错。
一.安装开发包(使用默认CENTOS更新源):
# yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype*
二.关闭iptables和SELINUX
# service iptables stop
# setenforce 0
# vi /etc/sysconfig/selinux
---------------
SELINUX=disabled
---------------
三.安装mysql数据库
1.下载编译包:
# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz/from/http://cdn.mysql.com/
2.安装前的初始配置工作:
# useradd -d /usr/local/mysql/ mysql #创建一个Mysql用户,指定家目录到/use/local目录下。
# mkdir /usr/local/mysql/data
# mkdir /usr/local/mysql/log #新建mysql下data和log子目录
# chown -R mysql:mysql /usr/local/mysql/data/
# chown -R mysql:mysql /usr/local/mysql/log/
# chmod 750 /usr/local/mysql/data
# chmod 750 /usr/local/mysql/log #修改目录的所属者以及所属组
3.解包编译安装
# tar -zxv -f mysql-5.6.13.tar.gz
# cd mysql-5.6.13
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=gbk \
-DDEFAULT_COLLATION=gbk_chinese_ci \
-DEXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DSYSCONFDIR=/etc \
-DWITH_SSL=yes
# make & make install
编译注解:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安装目录
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ #Unix socket文件路径,自定义此路径防报错
-DDEFAULT_CHARSET=gbk \ #默认字符
-DDEFAULT_COLLATION=gbk_chinese_ci \ #校验字符
-DEXTRA_CHARSETS=all \ #安装所有扩展字符集
-DWITH_MYISAM_STORAGE_ENGINE=1 \ #安装myisam存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ #安装innodb存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ #安装archive存储引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ #安装blackhole存储引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 \ #安装memory存储引擎
-DWITH_FEDERATED_STORAGE_ENGINE=1 \ #安装frderated存储引擎
-DWITH_READLINE=1 \ #快捷键功能
-DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据
-DMYSQL_DATADIR=/usr/local/mysql/data \ #数据库存放目录
-DMYSQL_USER=mysql \ #数据库属主
-DMYSQL_TCP_PORT=3306 \ #数据库端口
-DSYSCONFDIR=/etc \ #MySQL配辑文件
-DWITH_SSL=yes #数据库SSL
4.编写mysql配置项:
# vi /etc/my.cnf
--------------------------------------------
[mysql]
# CLIENT #
port = 3306
socket = /tmp/mysql.sock
[mysqld]
# GENERAL #
user = mysql
default_storage_engine = InnoDB
socket = /tmp/mysql.sock
pid_file = /var/run/mysqld/mysqld.pid
# MyISAM #
key_buffer_size = 32M
myisam_recover = FORCE,BACKUP
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate_is_now = 1
innodb = FORCE
innodb_strict_mode = 1
# DATA STORAGE #
datadir = /usr/local/mysql/data
# BINARY LOGGING #
log-bin =/usr/local/mysql/log/bin.log
expire_logs_days = 30
sync_binlog = 1
# CACHES AND LIMITS #
key_buffer = 256M
max_allowed_packet = 32M
sort_buffer_size = 16M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
thread_stack = 8M
tmp_table_size = 32M
max_heap_table_size = 32M
query_cache_type = 1
query_cache_size = 128M
query_cache_limit = 2M
max_connections = 2048
thread_cache_size = 512
open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 2048
# INNODB #
innodb_log_files_in_group = 2
innodb_log_file_size = 64M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
# 2G这个值配置低的话建议改小即可
innodb_buffer_pool_size = 2G
# LOGGING #
log-error=/usr/local/mysql/log/error.log
general_log=1
general_log_file=/usr/local/mysql/log/mysql.log
slow_query_log=1
slow_query_log_file=/usr/local/mysql/log/slowquery.log
log-output=FILE
# 避免MySQL的外部锁定,减少出错几率增强稳定性 #
skip-external-locking
# 禁止sql读取本地文件 #
local-infile=0