使用rpm包搭建LAMP(需要LAMP环境时候快速搭建)

来源:互联网 发布:库里20142015数据 编辑:程序博客网 时间:2024/06/03 02:27

(.删除系统中原有的http,mysql,php软件以及默认程序用户然后新建;//开源包最好做此步)

1安装http,mysql,php

[root@localhost.localdomain ~]
# yum install httpd* mysql* php*

Complete!

2启动httpd服务(如有需要可以配置域名)

# /etc/init.d/httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

                                                                                                                                                                                                                              [确定]

3启动mysqld服务(有一个初始化数据库的过程,如有需要可以设置密码)

[root@localhost.localdomain ~]
# /etc/init.d/mysqld start
初始化 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:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/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 /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

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

                                                           [确定]
正在启动 mysqld:                                          [确定]


4将index.php后台首页写入httpd的配置文件中并且重新启动httpd

[root@localhost.localdomain ~]
# vim /etc/httpd/conf/httpd.conf

DirectoryIndex index.html index.html.var index.php

[root@localhost.localdomain /usr]
# /etc/init.d/httpd restart
停止 httpd:                                               [确定]
正在启动 httpd:                                           [确定]

5测试httpd与php协同工作(编写test.php文件)

[root@localhost.localdomain /usr]
# vim /var/www/html/test.php   //在网页根目录下创建

<?php
        phpinfo();
?>

# vim /etc/httpd/conf/httpd.conf

访问http://SRV/test.php

6测试httpd,mysqld与php协同工作(编写testsql.php文件)

[root@localhost.localdomain /usr]
# vim /var/www/html/test.php

<?php
        $link= mysql_connect('localhost','root','');
        if($link) echo "connect successfully";
        mysql_close();

?>

[root@localhost.localdomain /usr]
# /etc/init.d/httpd restart
停止 httpd:                                               [确定]
正在启动 httpd:                                           [确定]

[root@localhost.localdomain /usr]
# /etc/init.d/mysqld restart
停止 mysqld:                                              [确定]
正在启动 mysqld:                                          [确定]

访问http://SRV/testsql.php





0 0
原创粉丝点击