源码包httpd-2.2.19.tar.bz2

                mysql-5.5.15-linux2.6-i686.tar.gz

                php-5.3.7.tar.bz2

利用上述×××lamp环境

详细步骤:

上传源码
[root@localhost ~]# ll
总计 174784
-rw------- 1 root root      1200 2012-08-21 anaconda-ks.cfg
drwxr-xr-x 2 root root      4096 08-20 21:47 Desktop
-rw-r--r-- 1 root root   5322082 08-20 22:03 httpd-2.2.19.tar.bz2
-rw-r--r-- 1 root root     35768 2012-08-21 install.log
-rw-r--r-- 1 root root      4713 2012-08-21 install.log.syslog
-rw-r--r-- 1 root root 162247449 08-20 22:04 mysql-5.5.15-linux2.6-i686.tar.gz
-rw-r--r-- 1 root root 11144328 08-20 22:03 php-5.3.7.tar.bz2
首先安装mysql
解压缩
tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local
[root@localhost local]# ln -s mysql-5.5.15-linux2.6-i686 mysql
[root@localhost local]# cd mysql
[root@localhost mysql]# groupadd mysql
[root@localhost mysql]# useradd -r -g mysql mysql
[root@localhost mysql]# cd /usr/local/
[root@localhost local]# cd mysql
改变文件所有者和所有组
[root@localhost mysql]# ll
总计 76
drwxr-xr-x 2 root root   4096 08-20 22:15 bin
-rw-r--r-- 1 7161 wheel 17987 2011-07-14 COPYING
drwxr-xr-x 4 root root   4096 08-20 22:15 data
drwxr-xr-x 2 root root   4096 08-20 22:16 docs
drwxr-xr-x 3 root root   4096 08-20 22:15 include
-rw-r--r-- 1 7161 wheel 7604 2011-07-14 INSTALL-BINARY
drwxr-xr-x 3 root root   4096 08-20 22:16 lib
drwxr-xr-x 4 root root   4096 08-20 22:14 man
drwxr-xr-x 10 root root   4096 08-20 22:15 mysql-test
-rw-r--r-- 1 7161 wheel 2552 2011-07-14 README
drwxr-xr-x 2 root root   4096 08-20 22:15 scripts
drwxr-xr-x 27 root root   4096 08-20 22:15 share
drwxr-xr-x 4 root root   4096 08-20 22:16 sql-bench
drwxr-xr-x 2 root root   4096 08-20 22:16 support-files
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# ll
总计 76
drwxr-xr-x 2 mysql mysql 4096 08-20 22:15 bin
-rw-r--r-- 1 mysql mysql 17987 2011-07-14 COPYING
drwxr-xr-x 4 mysql mysql 4096 08-20 22:15 data
drwxr-xr-x 2 mysql mysql 4096 08-20 22:16 docs
drwxr-xr-x 3 mysql mysql 4096 08-20 22:15 include
-rw-r--r-- 1 mysql mysql 7604 2011-07-14 INSTALL-BINARY
drwxr-xr-x 3 mysql mysql 4096 08-20 22:16 lib
drwxr-xr-x 4 mysql mysql 4096 08-20 22:14 man
drwxr-xr-x 10 mysql mysql 4096 08-20 22:15 mysql-test
-rw-r--r-- 1 mysql mysql 2552 2011-07-14 README
drwxr-xr-x 2 mysql mysql 4096 08-20 22:15 scripts
drwxr-xr-x 27 mysql mysql 4096 08-20 22:15 share
drwxr-xr-x 4 mysql mysql 4096 08-20 22:16 sql-bench
drwxr-xr-x 2 mysql mysql 4096 08-20 22:16 support-files
 
进行初始化
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
 
Alternatively you can run:
./bin/mysql_secure_installation
 
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
 
See the manual for more instructions.
 
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
 
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
 
Please report any problems with the ./bin/mysqlbug script!
 
[root@localhost mysql]#
 
改回所有者和所有组
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# ll
总计 76
drwxr-xr-x 2 root mysql 4096 08-20 22:15 bin
-rw-r--r-- 1 root mysql 17987 2011-07-14 COPYING
drwxr-xr-x 5 root mysql 4096 08-20 22:32 data
drwxr-xr-x 2 root mysql 4096 08-20 22:16 docs
drwxr-xr-x 3 root mysql 4096 08-20 22:15 include
-rw-r--r-- 1 root mysql 7604 2011-07-14 INSTALL-BINARY
drwxr-xr-x 3 root mysql 4096 08-20 22:16 lib
drwxr-xr-x 4 root mysql 4096 08-20 22:14 man
drwxr-xr-x 10 root mysql 4096 08-20 22:15 mysql-test
-rw-r--r-- 1 root mysql 2552 2011-07-14 README
drwxr-xr-x 2 root mysql 4096 08-20 22:15 scripts
drwxr-xr-x 27 root mysql 4096 08-20 22:15 share
drwxr-xr-x 4 root mysql 4096 08-20 22:16 sql-bench
drwxr-xr-x 2 root mysql 4096 08-20 22:16 support-files
data目录除外,所有者和所有组都是mysql
[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# ll
总计 76
drwxr-xr-x 2 root mysql 4096 08-20 22:15 bin
-rw-r--r-- 1 root mysql 17987 2011-07-14 COPYING
drwxr-xr-x 5 mysql mysql 4096 08-20 22:32 data
drwxr-xr-x 2 root mysql 4096 08-20 22:16 docs
drwxr-xr-x 3 root mysql 4096 08-20 22:15 include
-rw-r--r-- 1 root mysql 7604 2011-07-14 INSTALL-BINARY
drwxr-xr-x 3 root mysql 4096 08-20 22:16 lib
drwxr-xr-x 4 root mysql 4096 08-20 22:14 man
drwxr-xr-x 10 root mysql 4096 08-20 22:15 mysql-test
-rw-r--r-- 1 root mysql 2552 2011-07-14 README
drwxr-xr-x 2 root mysql 4096 08-20 22:15 scripts
drwxr-xr-x 27 root mysql 4096 08-20 22:15 share
drwxr-xr-x 4 root mysql 4096 08-20 22:16 sql-bench
drwxr-xr-x 2 root mysql 4096 08-20 22:16 support-files
拷贝配置文件
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf
启动mysql
[root@localhost mysql]# bin/mysqld_safe --user=mysql &
[1] 3782
[root@localhost mysql]# 120820 22:42:26 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdoma
120820 22:42:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
查看端口
[root@localhost mysql]# netstat -tupln |grep mysql
tcp        0      0 :::3306                     :::*                        LISTEN      4020/mysqld        
为使方便启动mysql可以用下列方式
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# service mysqld stop
Shutting down MySQL.120820 22:48:10 mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended
                                                           [确定]
[1]+ Done                    bin/mysqld_safe --user=mysql
[root@localhost mysql]# service mysqld start
Starting MySQL..                                           [确定]
[root@localhost mysql]# netstat -tupln |grep mysql
tcp        0      0 :::3306                     :::*                        LISTEN      4359/mysqld 
每次开机自动启用
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --list |grep mysql
mysqld            0:关闭      1:关闭      2:启用      3:启用      4:启用      5:启用      6:关闭
[root@localhost mysql]# chkconfig mysqld
[root@localhost mysql]# chkconfig mysqld
bin/            docs/           lib/            README          sql-bench/     
COPYING         include/        man/            scripts/        support-files/ 
data/           INSTALL-BINARY mysql-test/     share/         
[root@localhost mysql]# chkconfig mysqld on
[root@localhost mysql]#
调用库文件
[root@localhost mysql]# cd /etc/ld.so.conf.d/
[root@localhost ld.so.conf.d]# vim mysql.conf
/usr/local/mysql/lib
~                      
调用头文件
[root@localhost ld.so.conf.d]# cd /usr/local/mysql
[root@localhost mysql]# ll
总计 76
drwxr-xr-x 2 root mysql 4096 08-20 22:15 bin
-rw-r--r-- 1 root mysql 17987 2011-07-14 COPYING
drwxr-xr-x 5 mysql mysql 4096 08-20 22:48 data
drwxr-xr-x 2 root mysql 4096 08-20 22:16 docs
drwxr-xr-x 3 root mysql 4096 08-20 22:15 include
-rw-r--r-- 1 root mysql 7604 2011-07-14 INSTALL-BINARY
drwxr-xr-x 3 root mysql 4096 08-20 23:05 lib
drwxr-xr-x 4 root mysql 4096 08-20 22:14 man
drwxr-xr-x 10 root mysql 4096 08-20 22:15 mysql-test
-rw-r--r-- 1 root mysql 2552 2011-07-14 README
drwxr-xr-x 2 root mysql 4096 08-20 22:15 scripts
drwxr-xr-x 27 root mysql 4096 08-20 22:15 share
drwxr-xr-x 4 root mysql 4096 08-20 22:16 sql-bench
drwxr-xr-x 2 root mysql 4096 08-20 22:16 support-files
[root@localhost mysql]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/mysql/include/ mysql
 
安装apache
解压缩
[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src/
进入目录并查看
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# cd httpd-2.2.19/
[root@localhost httpd-2.2.19]# ls
ABOUT_APACHE buildconf      emacs-style INSTALL         LICENSE        os                srclib
acinclude.m4 CHANGES        httpd.dep    InstallBin.dsp Makefile.in    README            support
Apache.dsw    config.layout httpd.dsp    LAYOUT          Makefile.win   README.platforms test
build         configure      httpd.mak    libhttpd.dep    modules        README-win32.txt VERSIONING
BuildAll.dsp configure.in   httpd.spec   libhttpd.dsp    NOTICE         ROADMAP
BuildBin.dsp docs           include      libhttpd.mak    NWGNUmakefile server
 
[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl   --with-z
[root@localhost httpd-2.2.19]# make
[root@localhost httpd-2.2.19]#make install
[root@localhost httpd-2.2.19]# cd /usr/local/apache/
[root@localhost apache]# ll
总计 56
drwxr-xr-x 2 root root 4096 08-20 23:45 bin
drwxr-xr-x 2 root root 4096 08-20 23:46 build
drwxr-xr-x 2 root root 4096 08-20 23:45 cgi-bin
drwxr-xr-x 3 root root 4096 08-20 23:45 error
drwxr-xr-x 2 root root 4096 2011-05-21 htdocs
drwxr-xr-x 3 root root 4096 08-20 23:45 icons
drwxr-xr-x 2 root root 4096 08-20 23:45 include
drwxr-xr-x 4 root root 4096 08-20 23:45 lib
drwxr-xr-x 2 root root 4096 08-20 23:45 logs
drwxr-xr-x 4 root root 4096 08-20 23:46 man
drwxr-xr-x 14 root root 12288 2011-05-21 manual
drwxr-xr-x 2 root root 4096 08-20 23:45 modules
启动apache
[root@localhost apache]# cd bin/
[root@localhost bin]# ./apachectl start
[root@localhost bin]# netstat -tulpln |grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      24284/httpd  
调用库文件
[root@localhost ld.so.conf.d]# vim httpd.conf
/usr/local/apache/lib
~                   
调用头文件:
[root@localhost lib]# cd /etc/ld.so.conf.d/
[root@localhost include]# ln -s /usr/local/apache/include/ apache
安装php
[root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# cd php-5.3.7/
[root@localhostphp-5.3.7]#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-mbstring=all
[root@localhost php-5.3.7]# make
[root@localhost php-5.3.7]# make install
 
测试:
测试apache
 

 

测试php

 

[root@localhost htdocs]# vim index.html
[root@localhost htdocs]# mv index.html index.php
[root@localhost htdocs]# vim /etc/httpd/httpd.conf
AddType application/x-httpd-php.php
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
重启apache
[root@localhost htdocs]# /usr/local/apache/bin/apachectl stop
[root@localhost htdocs]# /usr/local/apache/bin/apachectl start

结果如下

 

 

 

  
Php调用mysql测试
 
[root@localhost htdocs]# vim index.php
<html><body><h1>It works!</h1></body></html>
<?php
$link=mysql_connect('127.0.0.1','root','');
if ($link)
 echo "yes";
else
 echo "no"
?>
 

 

 

进入mysql

[root@localhost htdocs]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.15-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql>