一、环境和软件包准备
[root@linuxidc ~]# cat/etc/RedHat-release
CentOS release 6.7 (Final)
[root@linuxidc ~]# uname -rm
2.6.32-573.el6.x86_64 x86_64
使用163的yum源
cd /etc/yum.repos.d/
wget
关闭防火墙和selinux
setenforce 0
service iptables stop
需要准备的软件包
mkdir /tools; cd /tools
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
httpd-2.4.16.tar.gz
curl-7.45.0.tar.gz
gettext-0.19.5.tar
libmcrypt-2.5.7.tar.gz
mcrypt-2.6.8.tar.gz
lpng1618.zip
mod_fastcgi-2.4.6.tar.gz
MySQL-5.6.26.tar.gz
php-5.5.30.tar.gz
phpMyAdmin-4.5.0.2-all-languages.zip
libpng-1.2.53.tar
freetype-2.4.0.tar
jpegsrc.v9.tar
opencart-2.1.0.1.zip
zlib-1.2.3.tar
……………….
注.版本不一定要一样。
二、安装依赖环境
yum -y groupinstall"Development Libraries"
yum -y groupinstall"Desktop Platform Development"
yum -y groupinstall "X Software Development"
yum -y install wget gcc gcc-c++ ncurses ncurses-devel cmakemake perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devellibjpeg* libpng* freetype* pcre-devel bzip2-devel libmcrypt-devel
三、编译安装apr
1、编译安装apr
cd /tools
tar xjvfapr-1.5.2.tar.bz2 -C /usr/src/;cd /usr/src/apr-1.5.2/
./configure--prefix=/usr/local/apr
make && makeinstall
2、编译安装apr-util
cd /tools/
tar xjvfapr-util-1.5.4.tar.bz2 -C /usr/src/;cd /usr/src/apr-util-1.5.4
./configure--prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make && make install
四、编译安装apache
cd /tools
tar xjvf httpd-2.4.17.tar.bz2 -C /usr/src/;cd /usr/src/httpd-2.4.17
./configure--prefix=/usr/local/apache2 --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util/ --with-mpm=event --enable-so--enable-mods-shared=all --enable-proxy=shared --enable-proxy-balancer=shared--enable-prosy-http=shared --enable-proxy-ajp --enable-deflate --enable-cache--enable-disk-cache --enable-mem-cachemake && make install
五、编译安装mysql
1、安装mysql
cd /tools
tar xzvfmysql-5.6.26.tar.gz -C /usr/src/;cd /usr/src/mysql-5.6.26
cmake-DENABLE_DOWNLOADS=1 -DCMAKE_INSTALL_PREFIX=/opt/mysql --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
make&& make install
2、创建相关设置
mkdir/data/mysql/{mysql-data,mysql-logs} –pv
groupadd -r -g 306 mysql
useradd -r -g 306 -u 306mysql
chown -R mysql.mysql/data/mysql/
编辑配置文件
vim /etc/my.cnf
添加如下内容
[mysql]
prompt= (\u@\h)[\d]>
[client]
port = 3306
socket = /tmp/mysql3306.sock
default_character_set = utf8
[mysqld]
user= mysql
port = 3306
socket = /tmp/mysql3306.sock
datadir =/data/mysql/mysql-data
pid_file = /data/mysql/mysql-data/mysql.pid
log-bin = /data/mysql/mysql-logs/mysql-bin
log-error = /data/mysql/mysql-logs/mysql.err
详细内容参考附件my.cnf
编辑启动脚本
vim/etc/rc.d/init.d/mysqld
添加和修改如下三行
basedir=/opt/mysql
datadir=/data/mysql/mysql-data
defaultconf=/etc/my.cnf
详细内容参考附件mysqld文件
设置启动脚本权限
chmod +x/etc/rc.d/init.d/mysqld
3、初始化数据库并启动
初始化数据库,执行完成后如果看到有两个OK,说明初始化成功了。
/opt/mysql/scripts/mysql_install_db--user=mysql --datadir=/data/mysql/mysql-data/ --basedir=/opt/mysql/ --defaults-file=/etc/my.cnf
启动数据库
[root@linuxidc tools]#/etc/rc.d/init.d/mysqld start
Starting MySQL.........SUCCESS!
把mysql命令加入环境变量
PATH=$PATH:/opt/mysql/bin/
chkconfig --add mysqld
chkconfig mysqld on
[root@linuxidc tools]# chkconfig --list mysqld
mysqld 0:off1:off2:on3:on4:on5:on6:off
使用service命令管理mysql进程
[root@linuxidc tools]# service mysqld stop
Shutting down MySQL.SUCCESS!
六、编译安装php
1、安装curl
cd /tools
tar xzvf curl-7.45.0.tar.gz-C /usr/src/;cd /usr/src/curl-7.45.0
./configure--prefix=/usr/local/curl && make && make install