Web服务基础六之编译安装配置RHEL+Apache+MySQL+PHP+ZendOptimize
一、准备工作1、开启80、3306端口,关闭selinux
# vim /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT
:FORWARD ACCEPT
:OUTPUT ACCEPT
-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-prohibited
COMMIT
# sestatus
SELinux status: disabled
# /etc/init.d/iptables restart
iptables: Flushing firewall rules:
iptables: Setting chains to policy ACCEPT: filter
iptables: Unloading modules:
iptables: Applying firewall rules:
# 2、下载软件包
软件源代码包存放位置:/usr/local/src 源码包编译安装位置:/usr/local/软件名字
a、下载apache
# cd /usr/local/src/
# wget http://www.apache.org/dist/httpd/httpd-2.4.7.tar.gz b、下载MySQL
http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/mysql-5.5.36.tar.gz
c、下载php
http://cn2.php.net/distributions/php-5.4.25.tar.gz
d、下载libmcrypt(PHPlibmcrypt模块)
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
e、下载apr(Apache库文件)
http://archive.apache.org/dist/apr/apr-1.5.0.tar.gz
f、下载apr-util(Apache库文件)
http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.3.tar.gz
g、下载Zend Guard(PHP加速软件)
http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
h、下载cmake(MySQL编译工具)
http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
# ls
apr-1.5.0.tar.gzlibmcrypt-2.5.7.tar.gzZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz cmake-2.8.12.2.tar.gz
apr-util-1.5.3.tar.gz mysql-5.5.36.tar.gz
httpd-2.4.7.tar.gz php-5.4.25.tar.gz
# 二、安装
a、安装编译工具及库文件
yum install make apr* autoconf automake gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gdkernel keyutilspatchperl 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
# tar zxvf libmcrypt-2.5.7.tar.gz
# cd libmcrypt-2.5.7
# ./configure
# make && make install c、安装cmake
# tar zxvf cmake-2.8.12.2.tar.gz
# cd cmake-2.8.12.2
# ./configure
# make && make install d、安装apr
# tar zxvf apr-1.5.0.tar.gz
# cd apr-1.5.0
# ./configure
# make && make install e、安装apr-util
# tar zxvf apr-util-1.5.3.tar.gz
# cd apr-util-1.5.3
# mkdir -p /usr/local/apr-util
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
# make && make installl f、安装mysql
# cd ..
# groupadd mysql
# useradd -g mysql mysql -s /sbin/nologin--禁止登陆
# mkdir -p /data/mysql --mysql数据库目录
# chown -R mysql:mysql /data/mysql/
# mkdir -p /usr/local/mysql--mysql安装目录
# tar zxvf mysql-5.5.36.tar.gz
# 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
# yum install -y ncurses-devel
# rm -f CMakeCache.txt
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc
# make && make install
# cd /usr/local/mysql/
# cp ./support-files/my-huge.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
# vim /etc/my.cnf
---该部分下
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
datadir = /data/mysql ---添加此行,指定数据库路径
# ./scripts/mysql_install_db --user=mysql--生成mysql系统数据库
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld--把Mysql加入系统启动
# chmod 755 /etc/init.d/mysqld
# chkconfig mysqld on
# vim /etc/rc.d/init.d/mysqld
46 basedir=/usr/local/mysql
47 datadir=/data/mysql
# /etc/init.d/mysqld start
Starting MySQL......
# vim /etc/profile--把mysql服务加入系统环境变量
export PATH=$PATH:/usr/local/mysql/bin --文末添加该行
# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
# ln -s /usr/local/mysql/include/mysql /usr/include/mysql--把myslq的库文件链接到系统默认的位置,在编译类似PHP等软件时可以不用指定mysql的库文件地址
# mysql_secure_installation
-bash: mysql_secure_installation: command not found--需要先重启系统
# init 6
# mysql_secure_installation
# service mysqld restart
Shutting down MySQL.
Starting MySQL...
# g、安装apache
# cd /usr/local/src/
# tar zxvf httpd-2.4.7.tar.gz
# cd httpd-2.4.7
# mkdir -p /usr/local/apache
# ./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
# make && make install
# /usr/local/apache/bin/apachectl -k start
# vim /usr/local/apache/conf/httpd.conf
191 ServerName localhost
249 DirectoryIndex index.html index.php
229 Options FollowSymLinks --不显示目录结构
236 AllowOverride All---开启apache支持伪静态
349 AllowOverride All
199 AllowOverride All
149 LoadModule rewrite_module modules/mod_rewrite.so--开启apache支持伪静态
# vi /etc/profile--添加apache服务系统环境变量
export PATH=$PATH:/usr/local/apache/bin--最后添加下面这一行
# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
cp: overwrite `/etc/rc.d/init.d/httpd'? y
# vim /etc/init.d/httpd
#!/bin/sh --添加以下两行
#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server
# chown daemon.daemon -R /usr/local/apache/htdocs
# chmod 700 !$
chmod 700 /usr/local/apache/htdocs
# chkconfig httpd on
# /etc/init.d/httpd start h、安装PHP
# tar zxvf php-5.4.25.tar.gz
# cd php-5.4.25
# mkdir -p /usr/local/php
# ./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
# make && make install
# cp php.ini-production /usr/local/php/etc/php.ini--复制php配置文件到安装目录
# rm -rf /etc/php.ini --删除系统自带的配置文件
# ln -s /usr/local/php/etc/php.ini /etc/php.ini--创建配置文件软链接
# vim /usr/local/php/etc/php.ini
309 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
# cd ..
# mkdir /usr/local/zend
# tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
# cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/--拷贝文件到安装目录
# j、配置PHP支持Zend Guard
# vim /usr/local/php/etc/php.ini--文末添加以下
zend_extension=/usr/local/zend/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path= k、配置Apache支持PHP
# vim /usr/local/apache/conf/httpd.conf
150 LoadModule php5_module modules/libphp5.so --此行后面添加以下行
151 AddType application/x-httpd-php .php--php .php这个点前面有一个空格
# service httpd restart
# service mysqld restart 三、测试
# cd /usr/local/apache/htdocs/
# vim index.php--添加以下内容
<?php
phpinfo();
?>
# mv index.html index.htmlbak 在浏览器里输入IP地址就可以访问到相关配置信息
网站程序上传到/usr/local/apache/htdocs/目录中,遇到安装问题,检查权限
# chown daemon.daemon -R /usr/local/apache/htdocs/
# chmod 700 -R /usr/local/apache/htdocs/ 至此RHEL+Apache+MySQL+PHP+ZendOptimize配置完成
###########################################################
关注微信平台,了解更多分享
2014,我们没有时间再去挥霍;
2014,我们需要学习以及坚持;
我们需要把等公交、乘地铁的时间一点点利用;
关注微信平台,随时都可以查看分享;
Linux,更需大家一起来分享。
Linux交流QQ群:333212786
################################################################################
页:
[1]