系统类型:rhel 5.6 x64

软件版本:apache 2.2.25 mysql 5.5.19 php 5.2.17


Apache安装


tar -zxvf httpd-2.2.25.tar.gz
cd httpd-2.2.25
./configure \
--prefix=/usr/local/apache \
--enable-mods-shared=all
make && make install


注:

1、只使用--enable-mods-shared=all选项时有些模块不会安装,例如:cache模块,如果需要,应该手动启用,例如:“--enable-cache”,安装后同样以DSO方式加载。

2、安装后可以手动禁用不需要的模块,注释掉对应的locadmodule行,重启生效。

3、只使用--enable-mods-shared=all选项,会安装以下模块:

[root@localhost ~]# /usr/local/apache/bin/httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c
[root@localhost ~]# /usr/local/apache/bin/httpd -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (shared)
 authn_dbm_module (shared)
 authn_anon_module (shared)
 authn_dbd_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_dbm_module (shared)
 authz_owner_module (shared)
 authz_default_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 dbd_module (shared)
 dumpio_module (shared)
 reqtimeout_module (shared)
 ext_filter_module (shared)
 include_module (shared)
 filter_module (shared)
 substitute_module (shared)
 deflate_module (shared)
 log_config_module (shared)
 log_forensic_module (shared)
 logio_module (shared)
 env_module (shared)
 mime_magic_module (shared)
 cern_meta_module (shared)
 expires_module (shared)
 headers_module (shared)
 ident_module (shared)
 usertrack_module (shared)
 unique_id_module (shared)
 setenvif_module (shared)
 version_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 asis_module (shared)
 info_module (shared)
 cgi_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 p_w_picpathmap_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
Syntax OK



清除执行程序标记符号

strip /usr/local/apache/bin/httpd


添加service程序管理

ln -s /usr/local/apache/bin/apachectl /etc/init.d/httpd


设置开机启动

vi /etc/init.d/httpd顶部添加以下内容:

###
# Comments to support chkconfig on RedHatLinux
# chkconfig: 3 85 15
# description:http server
###


chkconfig --add httpd


暂时关闭防火墙

service iptables stop





mysql安装


安装cmake(mysql5.5以后是通过cmake来编译的)


wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure &&make && make install


创建用户和用户组


useradd -M -s /sbin/nologin mysql


安装mysql


安装必须的包:

yum -y install ncurses-devel



tar zxvf mysql-5.5.19.tar.gz
cd mysql-5.5.19
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DMYSQL_DATADIR=/data/mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
/*出现警告:
CMake Warning:
      Manually-specified variables were not used by the project:
      MYSQL_USER
*/可以忽略……
make
make install


复制配置文件


  1. [root@mysql-5.5.11]# cp support-files/my-huge.cnf /etc/my.cnf

  2. [root@mysql-5.5.11]# cp support-files/mysql.server /etc/init.d/mysqld

  3. [root@mysql-5.5.11]# chmod 700 /etc/init.d/mysqld

初始化数据库:自动生成路径:/data/mysql,权限为700,属主mysql,属组root


/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/


设置开机启动

chkconfig --add mysqld ---默认2345启动

启动mysql

service mysqld start

为了方便使用mysql命令,执行以下命令

修改家目录.bash_profile

PATH=$PATH:/usr/local/mysql/bin

export PATH

mysql修改密码(安装后默认密码为空)

进入到mysql修改

#mysql

mysql>set password=password('123456');

或,直接使用命令修改:

mysqladmin -u root password 123456


php安装



提前把安装必要的包
yum -y install mysql-devel libjpeg-devel libmcrypt-devel libmhash-devel gd-devel libpng-devel openssl-devel curl-devel freetype-devel libxml2-devel
configure: error: libjpeg.(a|so) not found.
解决:cp -af /usr/lib64/libjpeg.so* /usr/lib
configure: error: libpng.(a|so) not found.
解决:cp -af /usr/lib64/libpng* /usr/lib
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:编辑安装libmcrypt
configure: error: Please reinstall libmhash – I cannot find mhash.h
解决:如果yum源无法安全,网上下载,然后再使用yum安装下载后的包
yum install mhash-0.9.9-1.el5.centos.i386.rpm
yum install mhash-devel-0.9.9-1.el5.centos.i386.rpm


-----------------------------------------------------------------------------------


tar -zxvf php-5.2.17.tar.gz
cd php-5.2.17
./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-pdo-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mcrypt \
--with-mhash \
--with-zlib \
--with-png-dir=/usr \
--with-freetype-dir=/usr \
--with-jpeg-dir=/usr \
--enable-gd-native-ttf \
--with-gd \
--enable-soap \
--enable-sockets \
--with-openssl \
--enable-zip \
--with-curl \
--enable-mbstring \
--enable-ftp
make
make install



将php配置文档复制到/usr/local/lib下


cp php.ini-recommended /usr/local/php/etc/php.ini

配置apache支持php


LoadModule php5_module modules/libphp5.so---默认安装php后自动添加此行
DocumentRoot "/data/webroot"---更改网站根目录
AddType application/x-httpd-php .php ---添加
index.php ---添加,如果是php网站,置index.html前




Zend安装

5.3之前的版本:进入解压后的目录执行./install,设置有关路径。

--------------------------------------

php5.3之后的版本:

知识:

从2000年10月20日发布的第一个Windows版的PHP3.0.17开始的都是线程安全的版本,这是由
于与Linux/Unix系统是采用多进程的工作方式不同的是Windows系统是采用多线程的工作方式。如果
在IIS下以CGI方式运行PHP会非常慢,这是由于CGI模式是建立在多进程的基础之上的,而非多线程。
一般我们会把PHP配置成以ISAPI的方式来运行,ISAPI是多线程的方式,这样就快多了。但存在一个
问题,很多常用的PHP扩展是以Linux/Unix的多进程思想来开发的,这些扩展在ISAPI的方式运行时就
会出错搞垮IIS。因此在IIS下CGI模式才是PHP运行的最安全方式,但CGI模式对于每个HTTP请求都
需要重新加载和卸载整个PHP环境,其消耗是巨大的。

为了兼顾IIS下PHP的效率和安全,微软给出了FastCGI的解决方案。FastCGI可以让PHP的进程重
复利用而不是每一个新的请求就重开一个进程。同时FastCGI也可以允许几个进程同时执行。这样既解决
了CGI进程模式消耗太大的问题,又利用上了CGI进程模式不存在线程安全问题的优势。

因此,如果是使用ISAPI的方式来运行PHP就必须用Thread Safe(线程安全)的版本;而用
FastCGI模式运行PHP的话就没有必要用线程安全检查了,用None Thread Safe(NTS,非线程安全)
的版本能够更好的提高效率。


配置:

下载Zend Guard Loader,提取ZendGuardLoader.so放到/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

修改php.ini,添加

zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=

重启apache