1、检测是否已经安装MySQL(Apache和PHP雷同)
[root@localhost ~]# rpm -qa | grep mysql (可能会是MySQL)
mysql-server-5.1.73-3.el6_5.x86_64
mysql-5.1.73-3.el6_5.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
2、卸载已安装的MySQL(Apache和PHP雷同)
[root@localhost ~]# rpm -e --nodeps mysql
[root@localhost ~]# rpm -e --nodeps mysql-server-5.1.73-3.el6_5.x86_64
[root@localhost ~]# rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64
3、rpm安装MySQL
下载mysql
[root@localhost ~]# wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.41-1.linux2.6.x86_64.rpm
(http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm)
[root@localhost ~]# wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.41-1.linux2.6.x86_64.rpm
(http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpm)
[root@localhost ~]# wget -c http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.41-1.linux2.6.x86_64.rpm
(http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.22-1.linux_glibc2.5.x86_64.rpm)
安装mysql
[root@localhost ~]# rpm -ivh MySQL-server-5.5.41-1.linux2.6.x86_64.rpm MySQL-client-5.5.41-1.linux2.6.x86_64.rpm MySQL-devel-5.5.41-1.linux2.6.x86_64.rpm
复制配置文件到加载位置
[root@localhost ~]# cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
修改远程登录设置
[root@localhost ~]# vi /etc/my.cnf
注释下面语句(如果有)
bind-address = 127.0.0.1
添加下面语句到 [ mysqld ] 部分的最后(如果没有)
skip-name-resolve
修改防火墙
[root@localhost ~]# vi /etc/sysconfig/iptables
加入以下三句(开放端口)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
开启mysql服务
[root@localhost ~]# service mysql start
开机自启动mysql服务
[root@localhost ~]# chkconfig mysql on
进入mysql
[root@localhost ~]# mysql -u root
设置远程登录权限
mysql> grant all on *.* to root@'%';
设置密码
mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('123456');
刷新权限修改
mysql> flush privileges;
4、安装Apache(httpd、apr、apr-util、pcre)
[root@localhost ~]# rpm -qa | grep httpd
httpd-2.2.15-15.el6.centos.1.x86_64
httpd-tools-2.2.15-15.el6.centos.1.x86_64
[root@localhost ~]# rpm -qa|grep apr
apr-util-ldap-1.3.9-3.el6_0.1.x86_64
apr-1.3.9-5.el6_2.x86_64
apr-util-1.3.9-3.el6_0.1.x86_64
[root@localhost ~]# rpm -qa|grep pcre
pcre-7.8-6.el6.x86_64
[root@localhost ~]# rpm -e --nodeps httpd-2.2.15-15.el6.centos.1.x86_64
[root@localhost ~]# rpm -e --nodeps httpd-tools-2.2.15-15.el6.centos.1.x86_64
[root@localhost ~]# rpm -e --nodeps apr-util-ldap-1.3.9-3.el6_0.1.x86_64
[root@localhost ~]# rpm -e --nodeps apr-1.3.9-5.el6_2.x86_64
[root@localhost ~]# rpm -e --nodeps apr-util-1.3.9-3.el6_0.1.x86_64
[root@localhost ~]# rpm -e --nodeps pcre-7.8-6.el6.x86_64
[root@localhost ~]# wget -c http://apache.fayea.com/httpd/httpd-2.4.10.tar.gz
[root@localhost ~]# wget -c http://apache.fayea.com/apr/apr-1.5.1.tar.gz
[root@localhost ~]# wget -c http://apache.fayea.com/apr/apr-util-1.5.4.tar.gz
[root@localhost ~]# yum -y install pcre pcre-devel
[root@localhost ~]# yum groupinstall "Development tools"
[root@localhost ~]# yum install openssl-devel
[root@localhost ~]# yum update openssl
[root@localhost ~]# tar zxvf apr-util-1.5.4.tar.gz
[root@localhost ~]# tar zxvf apr-1.5.1.tar.gz
[root@localhost ~]# tar zxvf httpd-2.4.10.tar.gz
[root@localhost ~]# cd apr-1.5.1
[root@localhostapr-1.5.1]# ./configure --prefix=/usr/local/apr
[root@localhostapr-1.5.1]# make && make install
[root@localhostapr-1.5.1]# cd ../
[root@localhost ~]# cd apr-util-1.5.4
[root@localhostapr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhostapr-util-1.5.4]# make && make install
[root@localhostapr-util-1.5.4]# cd ../
[root@localhost ~]# cd httpd-2.4.10
[root@localhost httpd-2.4.10]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-cgid --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@localhost httpd-2.4.10]# make && make install
配置启动脚本:
[root@localhost httpd-2.4.10]# cp build/rpm/httpd.init /etc/init.d/httpd
[root@localhost httpd-2.4.10]# vi /etc/init.d/httpd(红色为修改部分,/usr/local/apache2/ 是httpd的安装目录)
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
pidfile=${PIDFILE-/usr/local/apache2/logs/${prog}.pid}
lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
RETVAL=0
# check for 1.3 configuration
check13 () {
CONFFILE=/usr/local/apache2/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
GONE="${GONE}AccessConfig|ResourceConfig)"
if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
echo
echo 1>&2 " Apache 1.3 configuration directives found"
echo 1>&2 " please read @docdir@/migration.html"
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}
给予执行权限
[root@localhost httpd-2.4.10]# chmod 755 /etc/init.d/httpd
添加到开机启动服务项
[root@localhost httpd-2.4.10]# chkconfig --add httpd
创建软连接
[root@localhost httpd-2.4.10]# cd /usr/sbin/
[root@localhost sbin]# ln -s /usr/local/apache2/bin/* .
[root@localhost sbin]# ln -s /usr/local/apache2/logs /var/log/httpd
修改httpd配置项,增加服务器名称
[root@localhost ~]# vi /usr/local/apache2/conf/httpd.conf
在最开始添加
ServerName localhost
[root@localhost ~]# service httpd start