文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>LAMP安装手记

LAMP安装手记

时间:2005-07-26  来源:我是一个贼

LAMP安装手记(linux 9+apache 2.054+Mysql 5.09+php 5.04)

经过几天的努力,查阅N多资料之后,LAMP终于安装成功了,在此我要特别感谢鸟哥,鸟哥的linux私房菜给予了我大的帮助。

说明:所有软件我都放在/soft下,程序安装在/www下。

1.所需软件

php-5.0.4.tar.gz  点击下载

mysql-standard-5.0.9-beta-linux-i686.tar.gz  点击下载

httpd-2.0.54.tar.gz  点击下载

libxml2-2.6.20-1.i386.rpm  点击下载

 2.解压软件

[root@localhost www]# tar -zxvf /soft/httpd-2.0.54.tar.gz

[root@localhost www]# tar -zxvf /soft/mysql-standard-5.0.9-beta-linux-i686.tar.gz

root@localhost www]# tar -zxvf /soft/php-5.0.4.tar.gz

[root@localhost www]# ls

#经上面解压之后就会多出几个目录,可ls一下

httpd-2.0.54  mysql-standard-5.0.9-beta-linux-i686  php-5.0.4

 

3.安装mysql

#官方推荐以连接的方式进行安装,便于以后升级,以下是建立软件连接

[root@localhost www]# ln -s mysql-standard-5.0.9-beta-linux-i686 mysql

[root@localhost www]# ls

httpd-2.0.54  mysql  mysql-standard-5.0.9-beta-linux-i686  php-5.0.4

#多出了一个mysql目录 

[root@localhost www]# cd mysql

[root@localhost mysql]# ls

bin        docs               lib         scripts        tests

configure  EXCEPTIONS-CLIENT  man         share

COPYING    include            mysql-test  sql-bench

data       INSTALL-BINARY     README      support-files

#建立数据库,注意,先前必须先建立mysql用户,其实个人实验用呢,我觉得没有必须搞这么麻烦,直接用root就行了

[root@localhost mysql]# scripts/mysql_install_db --user=mysql

Installing all prepared tables

Fill help tables

 

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'

See the manual for more instructions.

 

You can start the MySQL daemon with:

cd . ; ./bin/mysqld_safe &

 

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:

cd sql-bench ; perl run-all-tests

 

Please report any problems with the ./bin/mysqlbug script!

 

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at https://order.mysql.com

[root@localhost mysql]# cd data/mysql

[root@localhost mysql]# ls

#php5的数据库放在data目录下

columns_priv.frm   help_keyword.MYD   proc.MYI                   time_zone_name.frm

columns_priv.MYD   help_keyword.MYI   procs_priv.frm             time_zone_name.MYD

columns_priv.MYI   help_relation.frm  procs_priv.MYD             time_zone_name.MYI

db.frm             help_relation.MYD  procs_priv.MYI             time_zone_transition.frm

db.MYD             help_relation.MYI  tables_priv.frm            time_zone_transition.MYD

db.MYI             help_topic.frm     tables_priv.MYD            time_zone_transition.MYI

func.frm           help_topic.MYD     tables_priv.MYI            time_zone_transition_type.frm

func.MYD           help_topic.MYI     time_zone.frm              time_zone_transition_type.MYD

func.MYI           host.frm           time_zone_leap_second.frm  time_zone_transition_type.MYI

help_category.frm  host.MYD           time_zone_leap_second.MYD  user.frm

help_category.MYD  host.MYI           time_zone_leap_second.MYI  user.MYD

help_category.MYI  proc.frm           time_zone.MYD              user.MYI

help_keyword.frm   proc.MYD           time_zone.MYI

[root@localhost mysql]# bin/safe_mysqld --user=mysql

#启动mysql,并查看

[root@localhost mysql]# ps

  PID TTY          TIME CMD

 4034 pts/1    00:00:00 bash

 4255 pts/1    00:00:00 mysqld_safe

 4370 pts/1    00:00:00 ps

 

#更改root密码 

 [root@localhost mysql]# bin/mysqladmin -u root password 'asdf'

#以root登陆mysql,并建立了addbook数据库,在addbook数据库中建立friends表,并做了插入,查询测试,结果一切正常,也就证明mysql安装成功

 [root@localhost mysql]# bin/mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 2 to server version: 5.0.9-beta-standard

 

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

 

mysql> create database addbook;

Query OK, 1 row affected (0.00 sec)

mysql> user addbook;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user addbook' at line 1

mysql> status

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

bin/mysql  Ver 14.11 Distrib 5.0.9-beta, for pc-linux-gnu (i686) using readline 4.3

 

Connection id:          3

Current database:       addbook

Current user:           root@localhost

SSL:                    Not in use

Current pager:          stdout

Using outfile:          ''

Using delimiter:        ;

Server version:         5.0.9-beta-standard

Protocol version:       10

Connection:             Localhost via UNIX socket

Server characterset:    latin1

Db     characterset:    latin1

Client characterset:    latin1

Conn.  characterset:    latin1

UNIX socket:            /tmp/mysql.sock

Uptime:                 10 min 51 sec

 

Threads: 1  Questions: 19  Slow queries: 0  Opens: 0  Flush tables: 1  Open tables: 1  Queries per second avg: 0.029

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

mysql> create table friends( name Char(15), tel VarChar(20), qq Char(10), address VarChar(30));

Query OK, 0 rows affected (0.01 sec)

mysql> show tables;

+-------------------+

| Tables_in_addbook |

+-------------------+

| friends           |

+-------------------+

1 row in set (0.00 sec)

mysql> insert into friends values('crazy','075512345678','4852189','shenzhen');

Query OK, 1 row affected (0.00 sec)

 

mysql> select * from friends;

+-------+--------------+---------+----------+

| name  | tel          | qq      | address  |

+-------+--------------+---------+----------+

| crazy | 075512345678 | 4852189 | shenzhen |

+-------+--------------+---------+----------+

1 row in set (0.00 sec)

mysql> exit;

Bye

 

#经上测试后,在data后可看到多了一个addbook目录,就是刚刚建立的addbook数据库

[root@localhost mysql]# ls data

addbook  mysql  test

[root@localhost mysql]#

 

#我查看在mysql目录下有configure文件,才开始时我想直接经configure安装(跳过了上scripts/mysql_install_db这个步骤),可是这样直接安装之后出错了,我看了configure内容,不知哪位给说说这个configure文件所起的作用,在此谢过。所以安装时还时以scripts/mysql_install_db安装数据库。

[root@localhost mysql]# ls

bin        COPYING  docs               include         lib  mysql-test  scripts  sql-bench      tests

configure  data     EXCEPTIONS-CLIENT  INSTALL-BINARY  man  README      share    support-files

[root@localhost mysql]# more configure

#!/bin/sh

if test ! -x  ./scripts/mysql_install_db

then

  echo "I didn't find the script './scripts/mysql_install_db'."

  echo "Please execute this script in the mysql distribution directory!"

  exit 1;

fi

 

echo "NOTE: This is a MySQL binary distribution. It's ready to run, you don't"

echo "need to configure it!"

echo ""

echo "To help you a bit, I am now going to create the needed MySQL databases"

echo "and start the MySQL server for you.  If you run into any trouble, please"

echo "consult the MySQL manual, that you can find in the Docs directory."

echo ""

 

./scripts/mysql_install_db --no-defaults

if [ $? = 0 ]

then

  echo "Starting the mysqld server.  You can test that it is up and running"

  echo "with the command:"

  echo "./bin/mysqladmin version"

  ./bin/mysqld_safe --no-defaults &

fi

4.安装httpd 

 

[root@localhost www]# cd httpd-2.0.54/

[root@localhost httpd-2.0.54]# ls

ABOUT_APACHE      build          configure.in  InstallBin.dsp  modules           server

acconfig.h        BuildBin.dsp   docs          LAYOUT          NOTICE            srclib

acinclude.m4      buildconf      emacs-style   libhttpd.dsp    NWGNUmakefile     support

Apache.dsp        CHANGES        httpd.spec    LICENSE         os                test

Apache.dsw        config.layout  include       Makefile.in     README            VERSIONING

apachenw.mcp.zip  configure      INSTALL       Makefile.win    README.platforms

[root@localhost httpd-2.0.54]#./configure --prefix=/www/apache2 --enable-so

#此时必须加上--enable-so参数据,以调用php时用

......

[root@localhost httpd-2.0.54]#make

......

[root@localhost httpd-2.0.54]#make install

......

[root@localhost www]# cd apache2/

[root@localhost apache2]# ls

bin    cgi-bin  error   icons    lib   man     modules

build  conf     htdocs  include  logs  manual

[root@localhost apache2]# cd bin

[root@localhost bin]# ls

ab          apu-config  dbmmanage    htdbm     httpd

apachectl   apxs        envvars      htdigest  logresolve

apr-config  checkgid    envvars-std  htpasswd  rotatelogs

#启动,测试

[root@localhost bin]# ./apachectl start

[root@localhost bin]# lynx 127.0.0.1

Test Page for Apache Installation

 

   If  you can see this, it means that the installation of the Apache web

   server software on this system was successful. You may now add content

   to this directory and replace this page.

                    ___________________________________

 

              Seeing this instead of the website you expected?

 

   This  page  is  here  because  the  site administrator has changed the

   configuration   of   this   web  server.  Please  contact  the  person

   responsible  for  maintaining  this  server with questions. The Apache

   Software  Foundation,  which  wrote  the web server software this site

   administrator  is  using, has nothing to do with maintaining this site

   and cannot help resolve configuration issues.

                    ___________________________________

 

   The Apache documentation has been included with this distribution.

 

   You  are  free to use the image below on an Apache-powered web server.

   Thanks for using Apache!

  

#测试成功,停止httpd

[root@localhost bin]# ./apachectl stop

 

5.安装php

#我在安装php时遇到的问题最多,

#第一个就是libxml2问题,由于redhat自带的libxml版本太低,可用(rpm -qa|grep libxml2)进行查看,所以先必须将其删除,注意,删除时要加上--nodeps参数,要不可能删除不了,然后再下载libxml2-2.6.20-1,安装时也得用--nodeps参数。

# 这是我安装完libxms2后的结果

[root@localhost php-5.0.4]# rpm -qa |grep libxml2

libxml2-2.6.20-1

 #有了上面的步骤,这样就可以安装php了, 

[root@localhost www]# cd php-5.0.4/

#第个问题,当用 ./configure --prefix=/www/php5 --with-apxs2=/www/apache2/bin/apxs --with-mysql=/www/mysql --with-config-file-path=/www/php5 时,出错,后来又加上了--disable-libxml参数,就可以了。

[root@localhost php-5.0.4]# ./configure --prefix=/www/php5 --with-apxs2=/www/apache2/bin/apxs --with-mysql=/www/mysql --with-config-file-path=/www/php5 --disable-libxml

.....

Thank you for using PHP.

[root@localhost php-5.0.4]#make

......

[root@localhost php-5.0.4]#make install

......

#看是否已经有了libphp5.so文件

 

[root@localhost php-5.0.4]# ls /www/apache2/modules/

httpd.exp  libphp5.so

[root@localhost php-5.0.4]# cp php.ini-dist /www/php5/php.ini

#编辑httpd.conf文件,加上以下两行,

[root@localhost php-5.0.4]# vi /www/apache2/conf/httpd.conf

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php .phtml .php3

#在htdocs目录下建立test.php文件,测试php

[root@localhost php-5.0.4]# vi /www/apache2/htdocs/test.php

phpinfo();

?>

#启动httpd,测试

[root@localhost php-5.0.4]# /www/apache2/bin/apachectl start

如果正常,一切就OK了。

 

 总结:

经过几天的实践经验,觉得最主要的是要多参考别人的安装方法,要多次尝试(不怕各位笑话,我为安装成功,重装linux不下十次,其实完全可以不必重新安装的,只要将其目录全部删除,再重新编辑就行了 ^-^),然后再总结出自己的安装方法。

望各位指教!

相关阅读 更多 +
排行榜 更多 +
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />

飞行射击 下载