LAMP全功能编译安装forCentOS6.3笔记(更新)在虚拟机上测试成功了LAMP各个最新版本的整合编译安装,算是把之前的博文整合精简,以下内容均在CENTOS6.3(安装minimaldesktop和默认开发包)下测试安装成功,并做了相应优化配置。LINUX操作系统:centOS6.364bit(安装了系统默认开发包)APACHE:httpd-2.4.4MYSQL:mysql-5.6.10PHP:php-5.4.13注:推荐安装centos6.3系统时,在系统安装向导中将默认开发包勾上,避免后期编译报错。一.安装开发包(使用默认CENTOS更新源):#yum-yinstallwgetgcc-c++ncursesncurses-develcmakemakeperlbisonopensslopenssl-develgcc*libxml2libxml2-develcurl-devellibjpeg*libpng*freetype*二.关闭iptables和SELINUX#serviceiptablesstop#setenforce0#vi/etc/sysconfig/selinux---------------SELINUX=disabled---------------三.安装mysql数据库1.下载编译包:#://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-Rmysql:mysql/usr/local/mysql/data/#chown-Rmysql:mysql/usr/local/mysql/log/#chmod750/usr/local/mysql/data#chmod750/usr/local/mysql/log#修改目录的所属者以及所属组3.解包编译安装#tar-zxv-fmysql-5.6.13.tar.gz#cdmysql-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&makeinstall编译注解:-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\#安装目录-DMYSQL_UNIX_ADDR=/tmp/mysql.sock\#Unixsocket文件路径,自定义此路径防报错-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#数据库SSL4.编写mysql配置项:#vi/etc/my.cnf--------------------------------------------[mysql]#CLIENT#port=3306socket=/tmp/mysql.sock[mysqld]#GENERAL#user=mysqldefault_storage_engine=InnoDBsocket=/tmp/mysql.sockpid_file=/var/run/mysqld/mysqld.pid#MyISAM#key_buffer_size=32Mmyisam_recover=FORCE,BACKUP#SAFETY#max_allowed_packet=16Mmax_connect_errors=1000000skip_name_resolvesql_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_BYsysdate_is_now=1innodb=FORCEinnodb_strict_mode=1#DATASTORAGE#datadir=/usr/local/mysql/data#BINARYLOGGING#log-bin=/usr/local/mysql/log/bin.logexpire_logs_days=30sync_binlog=1#CACHESANDLIMITS#key_buffer=256Mmax_allowed_packet=32Msort_buffer_size=16Mread_buffer_size=4Mread_rnd_buffer_size=16Mthread_stack=8Mtmp_table_size=32Mmax_heap_table_size=32Mquery_cache_type=1query_cache_size=128Mquery_cache_limit=2Mmax_connections=2048thread_cache_size=512open_files_limit=65535table_definition_cache=1024table_open_cache=2048#INNODB#innodb_log_files_in_group=2innodb_log_file_size=64Minnodb_flush_log_at_trx_commit=1innodb_file_per_table=1#2G这个值配置低的话建议改小即可innodb_buffer_pool_size=2G#LOGGING#log-error=/usr/local/mysql/log/error.loggeneral_log=1general_log_file=/usr/local/mysql/log/mysql.logslow_query_log=1slow_query_log_file=/usr/local/mysql/log/slowquery.loglog-output=FILE#避免MySQL的外部锁定,减少出错几率增强稳定性#skip-external-locking#禁止sql读取本地文件#local-infile=0----------------------------------------5.将mysql的库文件路径加入系统的库文件搜索路径中方法一:直接做软链接#ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql方法二:利用ldconfig导入系统库#echo/usr/local/mysql/lib/etc/ld.so.conf.d/mysql.conf#ldconfig6.输出mysql的头文件到系统头文件#ln-s/usr/local/mysql/include/mysql/usr/include/mysql7.进入安装路径,初始化配置脚本#cd/usr/local/mysql#scripts/mysql_install_db--user=mysql--datadir=/usr/local/mysql/data8.复制mysql启动脚本到系统服务目录#cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld9.系统启动项相关配置#chkconfig--addmysqld#添加开机启动服务#chkconfig--level35mysqldon#设置mysql启动10.启动mysql#servicemysqldstart注:编译时若socket路径自定义为/var/lib/mysql/mysql.sock,这里需要创建一个mysql接口的软链接,防止登陆后台或安装论坛报错.#ln-s/var/lib/mysql/mysql.sock/tmp/mysql.sock11.设置初始账户,并登陆后台:#/usr/local/mysql/bin/mysqladmin-urootpassword123456#设置密码#/usr/local/mysql/bin/mysql-uroot-p123456#连接数据库-----------------------------------mysqlcreatedatabasephpwind;#创建数据库mysqlgrantallprivilegeson*.*toroot@'%'identifiedby'123456'withgrantoption;#给root用户非本地链接所有权限,并改密码和赋予其给其他人下发权限.mysqlshowvariables;#查看mysql设置.-----------------------------------注:从启MYSQL也可使用以下命令开启此服务#/usr/local/mysql/bin/safe_mysqld如果不设置chkconfig启动项,也可在/etc/rc.local下添加如下命令,使mysql服务利用系统启动脚本运行.#echo/usr/local/mysql/bin/safe_mysqld--user=mysql&/etc/rc.local四.安装apache网站服务1.pcre依赖包安装#wget