LAMP即Linux+Apache+MySQL+PHPphp
centos5.3 64位镜像html
下载连接: http://pan.baidu.com/s/11QxVw 密码: 5zq6mysql
第一步:安装Apache2sql
1.切换到root用户, 输入yum install httpd, 选择yes, 自动安装,shell
2.版本:httpd-2.2.3-82.el5.centos.x86_64.rpm数据库
3.启动:/etc/init.d/httpd startapache
4.重启:/etc/init.d/httpd restartcentos
5.中止:/etc/init.d/httpd stop浏览器
6.查看运行状态:/etc/init.d/httpd status安全
关于apache的一些配置文件
1./etc/httpd/conf/httpd.conf:最主要的配置文件;
2./etc/httpd/conf.d/*.conf:这个是 CentOS 的特点, 若是你不想修改原始配置文件 httpd.conf 的话, 其余配置的在此独立配置, 启动 apache 时, 这个文件就会被读入到主要配置文件;
3./usr/lib/httpd/modules:apache 支持不少的模块, 您想要使用的模块默认都放置在此目录;
4./var/www/html:这里是 CentOS 默认的"首页"目录;
5./var/www/error:默认的系统错误信息, 主机设置错误或浏览器端要求的数据错误, 在浏览器上出现的错误提示就以这里的信息为主;
6./var/www/icons:提供 apache 的一些小图标;
7./var/www/cgi-bin:默认一些可执行的 CGI 程序放置的目录;
8./var/log/httpd:日志文件目录, 这里的文件很容易变的很大, 须要提供足够的空间;
9./usr/sbin/apachectl:这是 Apache 的主要执行文件, 这个执行文件实际上是 shell script, 它能够主动检测系统上的一些设置值, 好让您启动 Apache 时更简单;
10./usr/sbin/httpd:这是主要的 apache 的二进制文件;
11./usr/bin/htpasswd:当您想登录某些网页时, 须要输入帐号与密码. 那么Apache自己就提供一个最基本的密码保护方式, 该密码的产生就是经过这个命令实现的.
第二步:安装MySQL
1.安装命令:yum install mysql mysql-server
2.版本: mysql.i386 0:5.0.95-5.el5_9
mysql.x86_64 0:5.0.95-5.el5_9
mysql-server.x86_64 0:5.0.95-5.el5_9
3.启动服务:/etc/init.d/mysqld start
4.查看状态:/etc/init.d/mysqld status
5.设置root用户密码:mysqladmin -u root -p password 123456
Enter password:通常初始密码为空, 直接回车便可, 若是不是新用户则输入原密码
6.若是初始密码不为空, 或者忘记密码, 可经过如下方式重置root密码:
先中止mysql服务:/etc/init.d/mysqld stop
开启mysql安全模式:mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
开启新终端, 先切到root用户, 进入mysql,
[root@localhost /]# mysql -u root mysql mysql> update user set password=password('leaf') where user='root'; Query OK, 3 rows affected (0.01 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> quit; Bye
中止安全模式:/etc/init.d/mysqld stop
从新启动:/etc/init.d/mysqld start
7.登录mysql:mysql -u root -p
Enter password:密码
8./etc/my.cnf:这是Mysql的配置文件, 包括mysql 数据库的优化;
/usr/lib/mysql:这个目录是 MySQL 数据库放置的位置, 务必在备份时将此目录完整的备份下来
第三步:安装php5
1.命令:yum install php, 自行安装, 选yes, 安装过程很简单.
2.重启apache:/etc/init.d/httpd restart
3.测试. 在/var/www/html/ 下新建一个文件test.php
<html> <body> <?php phpinfo(); ?> </body> </html>
在浏览器中打开http://localhost/test.php , 会看到不少php的信息, 到此已经成功一大半了
第四步:使php支持mysql
1.安装所须要的支持包,
命令:yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
yum install php-mysql
2.重启apache:/etc/init.d/httpd restart
3.在浏览器中打开http://localhost/test.php , 会看到mysql的信息
第五步:配置apache和mysql开机启动
1.如系统中没有chkconfig, 需先安装chkconfig. 命令为:yum install chkconfig
2.在切换到root用户时, 要使用 su -, 没有-是不行的.
[root@localhost ~]# chkconfig --levels 3 httpd on
[root@localhost ~]# chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[root@localhost ~]# chkconfig --levels 3 mysqld on
[root@localhost ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:off 5:off 6:off
关于chkconfig的详细用法后续会介绍
到此LAMP搭建完成