(一)Apache服务的编译安装
1. 查找软件包位置[root@localhost ~]#cd /soft/LNS/chapter05[root@localhost ~]#ls2.解压包到指定位置[root@localhost ~]#tar zxf httpd-2.2.17.tar.gz -C /usr/src/3.编译安装Apache[root@localhost ~]#cd /usr/src/httpd-2.2.17/[root@localhost ~]#./configure --prefix=/usr/local/httpd --enable-rewrite --enable-charset-lite --enable-cgi ; make ; make install ;
[root@localhost ~]#ls /usr/local/httpd/4.优化执行路径[root@localhost ~]#ln -s /usr/local/httpd/bin/* /usr/local/bin/[root@localhost ~]#ls -l /usr/local/bin/apachectl /usr/local/bin/httpd
5.添加为系统服务[root@localhost ~]#cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd[root@localhost ~]#vi /etc/init.d/httpd (添加如下三行到页首)#!/bin/bash# chkconfig: 35 85 15# description: startup for Apache HTTP Server[root@localhost ~]#chkconfig --add httpd[root@localhost ~]#chkconfig --list httpd[root@localhost ~]#vi /usr/local/httpd/conf/httpd.conf 97 ServerName 6.检查配置文件语法是否正确[root@localhost ~]#apachectl -t[root@localhost ~]#cat /usr/local/httpd/htdocs/index.html [root@localhost ~]#/etc/init.d/httpd start[root@localhost ~]#netstat -anpt | grep httpd (二)Mysql的编译安装1.查找软件包位置[root@localhost ~]# cd /soft/LNS/chapter07/2.解压包到指定位置[root@localhost chapter07]# tar zxf mysql-5.1.55.tar.gz -C /usr/src/3.编译安装Mysql[root@localhost chapter07]# cd /usr/src/mysql-5.1.55/[root@localhost mysql-5.1.55]# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charset=gbk,gb2312; make ; make install ;4.拷贝样板到主配置文件[root@localhost mysql-5.1.55]# cp support-files/my-medium.cnf /etc/my.cnf5.创建运行帐号[root@localhost ~]# useradd -M -u 49 -s /sbin/nologin mysql6.初始化数据库[root@localhost mysql-5.1.55]# cd /usr/local/mysql/bin/[root@localhost bin]# ./mysql_install_db --user=mysql7.修改数据库文件夹的属主及属组[root@localhost bin]# chown -R root:mysql /usr/local/mysql/[root@localhost bin]# chown -R mysql /usr/local/mysql/var/8.优化执行路径,程序库路径[root@localhost bin]# ln -s /usr/local/mysql/bin/* /usr/local/bin/[root@localhost bin]# ln -s /usr/local/mysql/lib/mysql/* /usr/lib/[root@localhost bin]# ln -s /usr/local/mysql/include/mysql/* /usr/include/9.添加系统服务[root@localhost ~]# cd /usr/src/mysql-5.1.55/[root@localhost mysql-5.1.55]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld[root@localhost mysql-5.1.55]# chmod +x /etc/rc.d/init.d/mysqld [root@localhost mysql-5.1.55]# chkconfig --add mysqld[root@localhost mysql-5.1.55]# service mysqld startStarting MySQL. [确定][root@localhost mysql-5.1.55]# netstat -anptl | grep mysqldtcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 14016/mysqld 10.启动mysqld服务,为root用户设置密码,删除空用户[root@localhost ~]# mysqladmin -u root password "666666"[root@localhost ~]# mysql -u -p666666Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.55-log Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
(三)PHP的编译安装一.准备工作(先查看下,有没有安装这个软件)[root@localhost ~]# rpm -q php php-cli php-ldap php-common php-mysql --nodepspackage php is not installedpackage php-cli is not installedpackage php-ldap is not installedpackage php-common is not installedpackage php-mysql is not installed二。安装扩展工具库--数据加密工具libmcrypt、mhash、mcrypt安装libmcrypt软件[root@localhost ~]# cd /soft/LNS/chapter08/[root@localhost chapter08]# tar zxf libmcrypt-2.5.8.tar.gz -C /usr/src/[root@localhost chapter08]# cd /usr/src/libmcrypt-2.5.8/[root@localhost libmcrypt-2.5.8]# ./configure ; make ; make install 将/usr/local/lib/libmcrypt.* 超链接到 /usr/lib/下[root@localhost libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib安装mhash[root@localhost ~]# cd /soft/LNS/chapter08/[root@localhost chapter08]# tar zxf mhash-0.9.9.9.tar.gz -C /usr/src/[root@localhost chapter08]# cd /usr/src/mhash-0.9.9.9/[root@localhost mhash-0.9.9.9]# ./configure ; make ; make install 将/usr/local/lib/libmhash* 超链接到/usr/lib/下[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash* /usr/lib/安装mcrypt[root@localhost ~]# cd /soft/LNS/chapter08/[root@localhost chapter08]# tar zxf mcrypt-2.6.8.tar.gz -C /usr/src/[root@localhost chapter08]# cd /usr/src/mcrypt-2.6.8/[root@localhost mcrypt-2.6.8]# ./configure ; make ; make install 三.编译安装PHP[root@localhost ~]# cd /soft/LNS/chapter08/[root@localhost chapter08]# lslibmcrypt-2.5.8.tar.gz php-5.3.6.tar.gz ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gzmcrypt-2.6.8.tar.gz phpMyAdmin-2.11.11.3-all-languages.tar.gz ZendGuardLoader.somhash-0.9.9.9.tar.gz phpMyAdmin-3.3.10-all-languages.tar.gz[root@localhost chapter08]# tar zxf php-5.3.6.tar.gz -C /usr/src/[root@localhost chapter08]# cd /usr/src/php-5.3.6/[root@localhost php-5.3.6]# ./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring ; make ; make install 四.安装后的调整[root@localhost php-5.3.6]# cp /usr/src/php-5.3.6/php.ini-development /usr/local/php5/php.ini[root@localhost php-5.3.6]# vi /usr/local/php5/php.ini226 short_open_tag = On 修改php主配置文件,使之支持使用简洁标志,772 default_charset = "utf-8" 修改默认字符集为utf-8添加ZendGuardLoader优化模块1895 zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so1896 zend_loader.enable=1五.httpd.conf配置调整,使httpd服务器支持PHP页面解析功能[root@localhost ~]# vi /usr/local/httpd/conf/httpd.conf167 DirectoryIndex index.php index.html 添加index.php310 AddType application/x-httpd-php .php 添加该行六.编写测试页[root@localhost ~]# vi /usr/local/httpd/htdocs/test.php<?phpphpinfo();?>[root@localhost ~]# vi /usr/local/httpd/htdocs/test2.php<?php$link=mysql_connect('localhost','root','666666');if($link) echo "php已成功创建并连接到数据库";mysql_close();?>
本文出自 “” 博客,请务必保留此出处