一、准备工作
1、开启80、3306端口,关闭selinux
[root@justin ~]# vim /etc/sysconfig/iptables# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-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-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT[root@justin ~]# sestatusSELinux status: disabled[root@justin ~]# /etc/init.d/iptables restartiptables: Flushing firewall rules: [ OK ]iptables: Setting chains to policy ACCEPT: filter [ OK ]iptables: Unloading modules: [ OK ]iptables: Applying firewall rules: [ OK ][root@justin ~]#
2、下载软件包
软件源代码包存放位置:/usr/local/src 源码包编译安装位置:/usr/local/软件名字
a、下载apache
[root@justin ~]# cd /usr/local/src/[root@justin src]# wget http://www.apache.org/dist/httpd/httpd-2.4.7.tar.gz
b、下载MySQL
c、下载php
d、下载libmcrypt(PHPlibmcrypt模块)
e、下载apr(Apache库文件)
f、下载apr-util(Apache库文件)
g、下载Zend Guard(PHP加速软件)
z
h、下载cmake(MySQL编译工具)
[root@justin src]# lsapr-1.5.0.tar.gz libmcrypt-2.5.7.tar.gz ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz cmake-2.8.12.2.tar.gzapr-util-1.5.3.tar.gz mysql-5.5.36.tar.gzhttpd-2.4.7.tar.gz php-5.4.25.tar.gz[root@justin src]#
二、安装
a、安装编译工具及库文件
yum install make apr* autoconf automake gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch -y
b、安装libmcrypt
[root@justin src]# tar zxvf libmcrypt-2.5.7.tar.gz[root@justin src]# cd libmcrypt-2.5.7[root@justin libmcrypt-2.5.7]# ./configure[root@justin libmcrypt-2.5.7]# make && make install
c、安装cmake
[root@justin src]# tar zxvf cmake-2.8.12.2.tar.gz[root@justin src]# cd cmake-2.8.12.2[root@justin cmake-2.8.12.2]# ./configure[root@justin cmake-2.8.12.2]# make && make install
d、安装apr
[root@justin src]# tar zxvf apr-1.5.0.tar.gz[root@justin src]# cd apr-1.5.0[root@justin apr-1.5.0]# ./configure[root@justin apr-1.5.0]# make && make install
e、安装apr-util
[root@justin src]# tar zxvf apr-util-1.5.3.tar.gz[root@justin src]# cd apr-util-1.5.3[root@justin apr-util-1.5.3]# mkdir -p /usr/local/apr-util[root@justin apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config[root@justin apr-util-1.5.3]# make && make installl
f、安装mysql
[root@justin apr-util-1.5.3]# cd ..[root@justin src]# groupadd mysql[root@justin src]# useradd -g mysql mysql -s /sbin/nologin --禁止登陆[root@justin src]# mkdir -p /data/mysql --mysql数据库目录[root@justin src]# chown -R mysql:mysql /data/mysql/[root@justin src]# mkdir -p /usr/local/mysql --mysql安装目录[root@justin src]# tar zxvf mysql-5.5.36.tar.gz[root@justin mysql-5.5.36]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)CMake Error at cmake/readline.cmake:83 (MESSAGE): Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
出错了,提示RHEL平台安装ncurses-devel并删除CMakeCache.txt
[root@justin mysql-5.5.36]# yum install -y ncurses-devel[root@justin mysql-5.5.36]# rm -f CMakeCache.txt[root@justin mysql-5.5.36]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc[root@justin mysql-5.5.36]# make && make install[root@justin mysql-5.5.36]# cd /usr/local/mysql/[root@justin mysql]# cp ./support-files/my-huge.cnf /etc/my.cnfcp: overwrite `/etc/my.cnf'? y[root@justin mysql]# vim /etc/my.cnf[mysqld] ---该部分下port = 3306socket = /tmp/mysql.sockskip-external-lockingdatadir = /data/mysql ---添加此行,指定数据库路径[root@justin mysql]# ./scripts/mysql_install_db --user=mysql --生成mysql系统数据库[root@justin mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld --把Mysql加入系统启动[root@justin mysql]# chmod 755 /etc/init.d/mysqld[root@justin mysql]# chkconfig mysqld on[root@justin mysql]# vim /etc/rc.d/init.d/mysqld 46 basedir=/usr/local/mysql 47 datadir=/data/mysql[root@justin mysql]# /etc/init.d/mysqld startStarting MySQL...... [ OK ][root@justin mysql]# vim /etc/profile --把mysql服务加入系统环境变量export PATH=$PATH:/usr/local/mysql/bin --文末添加该行[root@justin mysql]# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql[root@justin mysql]# ln -s /usr/local/mysql/include/mysql /usr/include/mysql --把myslq的库文件链接到系统默认的位置,在编译类似PHP等软件时可以不用指定mysql的库文件地址[root@justin mysql]# mysql_secure_installation-bash: mysql_secure_installation: command not found --需要先重启系统[root@justin mysql]# init 6[root@justin ~]# mysql_secure_installation[root@justin ~]# service mysqld restartShutting down MySQL. [ OK ]Starting MySQL... [ OK ][root@justin ~]#
g、安装apache
[root@justin src]# cd /usr/local/src/[root@justin src]# tar zxvf httpd-2.4.7.tar.gz[root@justin src]# cd httpd-2.4.7[root@justin httpd-2.4.7]# mkdir -p /usr/local/apache[root@justin httpd-2.4.7]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --enable-ssl --enable-module=so --enable-rewrite --enable-cgid --enable-cgi[root@justin httpd-2.4.7]# make && make install[root@justin httpd-2.4.7]# /usr/local/apache/bin/apachectl -k start[root@justin httpd-2.4.7]# vim /usr/local/apache/conf/httpd.conf191 ServerName localhost249 DirectoryIndex index.html index.php229 Options FollowSymLinks --不显示目录结构236 AllowOverride All ---开启apache支持伪静态349 AllowOverride All199 AllowOverride All149 LoadModule rewrite_module modules/mod_rewrite.so --开启apache支持伪静态[root@justin httpd-2.4.7]# vi /etc/profile --添加apache服务系统环境变量export PATH=$PATH:/usr/local/apache/bin --最后添加下面这一行[root@justin httpd-2.4.7]# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpdcp: overwrite `/etc/rc.d/init.d/httpd'? y[root@justin httpd-2.4.7]# vim /etc/init.d/httpd#!/bin/sh --添加以下两行#chkconfig:2345 10 90#description:Activates/Deactivates Apache Web Server[root@justin httpd-2.4.7]# chown daemon.daemon -R /usr/local/apache/htdocs[root@justin httpd-2.4.7]# chmod 700 !$chmod 700 /usr/local/apache/htdocs[root@justin httpd-2.4.7]# chkconfig httpd on[root@justin httpd-2.4.7]# /etc/init.d/httpd start
h、安装PHP
[root@justin src]# tar zxvf php-5.4.25.tar.gz[root@justin src]# cd php-5.4.25[root@justin php-5.4.25]# mkdir -p /usr/local/php[root@justin php-5.4.25]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-freetype --with-jpeg --with-png --with-zlib --with-libxml --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable-suhosin --enable-session --with-mcrypt[root@justin php-5.4.25]# make && make install[root@justin php-5.4.25]# cp php.ini-production /usr/local/php/etc/php.ini --复制php配置文件到安装目录[root@justin php-5.4.25]# rm -rf /etc/php.ini --删除系统自带的配置文件[root@justin php-5.4.25]# ln -s /usr/local/php/etc/php.ini /etc/php.ini --创建配置文件软链接[root@justin php-5.4.25]# vim /usr/local/php/etc/php.ini309 open_basedir = .:/tmp/ 315 disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_ status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_sock et_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbypo rt,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,p osix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getp grp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix _getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setp gid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname --列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用 919 date.timezone = PRC 376 expose_php = OFF --禁止显示php版本的信息 479 display_errors = OFF --关闭错误提示
i、安装Zend Guard
[root@justin php-5.4.25]# cd ..[root@justin src]# mkdir /usr/local/zend[root@justin src]# tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz[root@justin src]# cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ --拷贝文件到安装目录[root@justin src]#
j、配置PHP支持Zend Guard
[root@justin src]# vim /usr/local/php/etc/php.ini --文末添加以下[Zend Guard]zend_extension=/usr/local/zend/ZendGuardLoader.sozend_loader.enable=1zend_loader.disable_licensing=0zend_loader.obfuscation_level_support=3zend_loader.license_path=
k、配置Apache支持PHP
[root@justin src]# vim /usr/local/apache/conf/httpd.conf150 LoadModule php5_module modules/libphp5.so --此行后面添加以下行151 AddType application/x-httpd-php .php --php .php这个点前面有一个空格[root@justin src]# service httpd restart[root@justin src]# service mysqld restart
三、测试
[root@justin src]# cd /usr/local/apache/htdocs/[root@justin htdocs]# vim index.php --添加以下内容 [root@justin htdocs]# mv index.html index.htmlbak
在浏览器里输入IP地址就可以访问到相关配置信息
网站程序上传到/usr/local/apache/htdocs/目录中,遇到安装问题,检查权限
[root@justin htdocs]# chown daemon.daemon -R /usr/local/apache/htdocs/[root@justin htdocs]# chmod 700 -R /usr/local/apache/htdocs/
至此RHEL+Apache+MySQL+PHP+ZendOptimize配置完成
###########################################################
关注微信平台,了解更多分享
2014,我们没有时间再去挥霍;2014,我们需要学习以及坚持;我们需要把等公交、乘地铁的时间一点点利用;关注微信平台,随时都可以查看分享;Linux,更需大家一起来分享。Linux交流QQ群:333212786################################################################################