- 系统版本
Centos6.5 已安装开发工具
- 所需源码包及版本
--Apache
- httpd - 2.2.31.tar.gz
--MySQL
- cmake - 2.8.6.tar.gz mysql - 5.5.22.tar.gz
--PHP
- libmcrypt - 2.5.8.tar.gz zxfmhash - 0.9.9.9.tar.gz mcrypt - 2.6.8.tar.gz php - 5.3.6.tar.gz ZendGuardLoader.so
- 卸载已有 httpd
- rpm - e httpd –nodeps
- 编译安装
- tar zxf httpd - 2.2.31.tar.gz cd httpd - 2.2.31. / configure --prefix = /usr/local / httpd--enable - so --enable - rewrite --enable - charset - lite --enable - cgi make make install
-- 注:
--prefix:指定将 httpd 服务程序安装到哪个目录,如 / usr/local/httpd。
--enable-so:启用动态加载模块支持,使 httpd 具备进一步扩展功能的能力。
--enable-rewrite:启用网页地址 (url) 重写功能,用于网站优化及目录迁移维护。
--enable-charset-lite:启动字符集支持,以便支持使用各种字符集编码的网页。
--enable-cgi:启用 CGI 脚本程序支持,便于扩展网站的应用访问能力。
- 优化执行路径
- ln - s / usr / local / httpd / bin
- /* /usr/local/bin/*/
- 添加 httpd 系统服务
- cp / usr / local / httpd / bin / apachectl / etc / init.d / httpd echo "
- #chkconfig:3590 20
- " >> / etc / init.d / httpd chmoda + x / etc / init.d / httpd chkconfig--add httpd
- 启动服务,测试
略
- 准备工作
- rpm - e mysql mysql - server –nodeps yum - y install ncurses - devel
- 安装 cmake
- cd / usr / src tarzxf cmake - 2.8.6.tar.gz cdcmake - 2.8.6 . / configure gmake gmakeinstall
- 添加程序用户
- useradd - M - s / sbin / nologin mysql
- 安装 mysql
- cd / usr / src tarzxf mysql - 5.5.22.tar.gz cdmysql - 5.5.22 cmake - DCMAKE_INSTALL_PREFIX = /usr/local / mysql - DSYSCONFDIR = /etc-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all
- make
- makeinstall/
-- 注:
-DEXTRA_CHARSETS=all 启用额外的字符集类型(默认为 all)
-DDEFAULT_CHARSET=utf8 指定默认的字符集为 utf8
-DDEFAULT_COLLATION=utf8_general_ci 设定默认排序规则(utf8_general_ci 快速 / utf8_unicode_ci 准确)
- 安装后调整
- chown - R mysql: mysql / usr / local / mysql cd / usr / src / mysql - 5.5.22 cpsupport - files / my - medium.cnf / etc / my.cnf / usr / local / mysql / scripts / mysql_install_db--user = mysql --basedir = /usr/local / mysql --datadir = /usr/local / mysql / data / echo "PATH=$PATH:/usr/local/mysql/bin" >> / etc / profile source / etc / profile
- 添加系统服务
- cpsupport - files / mysql.server / etc / init.d / mysqld chmod + x / etc / init.d / mysqld chkconfig--add mysqld
- 启动服务
- servicemysqld start
- 准备
- rpm - e php php - cli php - ldap php - common php - mysql –nodeps
- 安装数据加密工具 libmcrypt、mhash、mcrypt(有顺序,依次安装)
- #libmcrypt - 2.5.8 cd / usr / src tarzxf libmcrypt - 2.5.8.tar.gz cd / usr / src / libmcrypt - 2.5.8 / . / configure make && make install ln - s / usr / local / lib / libmcrypt. * / usr / lib / #mhash - 0.9.9.9 cd / usr / src tarzxf mhash - 0.9.9.9.tar.gz cd / usr / src / mhash - 0.9.9.9 / . / configure make && make install ln - s / usr / local / lib / libmhash * / usr / lib / #mcrypt - 2.6.8 cd / usr / src tarzxf mcrypt - 2.6.8.tar.gz cd / usr / src / mcrypt - 2.6.8 / exportLD_LIBRARY_PATH = /usr/local / lib: $LD_LIBRARY_PATH . / configure make && make install
- 编译安装 PHP
- cd / usr / src tarzxf php - 5.3.6.tar.gz - C / usr / src / cd / usr / src / php - 5.3.6 / . / configure--prefix = /usr/local / php5 --with - mcrypt--with - apxs2 = /usr/local / httpd / bin / apxs --with - config - file - path = /usr/local / php5 --enable - mbstring--with - mysql = mysqlnd --with - mysqli = mysqlnd --with - pdo - mysql = mysqlnd make makeinstall
-- 注:
--prefix:指定将 php 程序安装到哪个目录,如 / usr/local/php5。
--with-mcrypt:加载数据加密等扩展工具支持。
--with-apxs2:设置 Apache HTTP Server 提供的 apxs 模块支持程序的文件位置。
--with-mysql:设置 MySQL 数据库服务程序的安装位置。
--with-config-file-path:设置 PHP 的配置文件 php.ini 将要存放的位置。
--enable-mbstring:启用多字节字符串功能,以便支持中文等代码。
- 复制样例文件
- cp / usr / src / php - 5.3.6 / php.ini - development / usr / local / php5 / php.ini
- 修改配置选项
- sed - i 's / ;
- default_charset = "iso-8859-1" / default_charset = "utf-8" / ' / usr / local / php5 / php.ini sed - i 's / short_open_tag = Off / short_open_tag = On / ' / usr / local / php5 / php.ini
- 添加优化模块
- cp / usr / src / ZendGuardLoader.so / usr / local / php5 / lib / php / echo "
- zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
- zend_loader.enable=1 " >> /usr/local / php5 / php.ini
-httpd.conf 配置调整
- sed - i '385a AddType application / x - httpd - php .php' / usr / local / httpd / conf / httpd.conf sed - i 's / DirectoryIndex index.html / DirectoryIndex index.php index.html / ' / usr / local / httpd / conf / httpd.conf
- echo "
- <?php
- \$link = mysql_connect ('localhost','root','');
- if(\$link) echo \"数据库连接成功!!!!\";
- mysql_close();
- ?>
- " > / usr / local / httpd / htdocs / test.php
启动 httpd 和 mysqld 服务
浏览器访问:,页面输出 "数据库连接成功!!!!",证明搭建成功。
来源: http://www.bubuko.com/infodetail-1858306.html