LAMP之平台搭建
项目描述
近期因朋友需求,想要自己做个网站,已得到网站源码,需要查看网站效果,因而咨询于我。奈于自身学艺不精,攻业不深,基于Windows平台的PHP环境始终出问题(IIS和Apache都让我好崩溃,连WAMP都用了,配置就是不行,唉~~),无法查看到效果,甚至焦心。
由于时间紧迫,朋友对我又比较信任,索性使用相对熟悉的Linux平台,优点就是便捷、迅速还省事儿,遂有此文!
废话不多说,直接上干货!
项目资源
项目平台资源:基于Vmware 8.0
项目环境资源:Red Hat Enterprise Linux 5(LAMP)
项目软件包资源:基于RHEL5光盘文件
项目实施及操作流程
1.挂载光盘
2.安装相关服务及其软件包(主要包含DNS服务,Apache服务,MySQL服务,PHP服务)
3.配置相关文件及参数
操作流程:
/*挂载光盘*/
[root@LAMP~]# mount /dev/cdrom /mnt
mount:block device /dev/cdrom is write-protected, mounting read-only
/*进入光盘*/
[root@LAMP~]# cd /mnt/Server/
/*安装DNS服务bind和caching-nameser包*/
[root@LAMPServer]# rpm -ivh bind-9.3.3-7.el5.i386.rpmcaching-nameserver-9.3.3-7.el5.i386.rpm
warning:bind-9.3.3-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...###########################################[100%]
1:bind########################################### [ 50%]
2:caching-nameserver########################################### [100%]
/*编辑DNS配置文件*/
[root@LAMPServer]# vim /etc/named.caching-nameserver.conf
options{
//listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };
directory"/var/named";
dump-file"/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file"/var/named/data/named_mem_stats.txt";
query-sourceport 53;
query-source-v6 port 53;
//allow-query{ localhost; };
};
logging{
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
viewlocalhost_resolver {
//match-clients{ localhost; };
//match-destinations { localhost; };
recursion yes;
include"/etc/named.rfc1912.zones";
};
/*编辑区域配置文件*/
[root@LAMPServer]# vim /etc/named.rfc1912.zones
/*新增区域*/
zone"test.com" IN {
type master;
file "test.com.zone";
};
/*为新增区域创建配置文件*/
[root@LAMPServer]# vim /var/named/test.com.zone
@ IN SOA ns.test.com. root.test.com. (
20130509
28800
14400
3600000
86400
)
@ IN NS ns.test.com.
ns IN A 192.168.79.2
www IN CNAME ns.test.com.
/*查看新增文件*/
[root@LAMPServer]# ls /var/named/
chrootlocalhost.zonenamed.ip6.localslaves
datanamed.broadcastnamed.localtest.com.zone
localdomain.zonenamed.canamed.zero
/*启动DNS服务,并使用nslookup和ping命令验证解析*/
[root@LAMPServer]# service named start
Startingnamed:[OK]
[root@LAMPServer]# nslookup www.test.com
Server:192.168.79.2
Address:192.168.79.2#53
www.test.comcanonical name = ns.test.com.
Name:ns.test.com
Address:192.168.79.2
[root@LAMPServer]# ping www.test.com
PINGns.test.com (192.168.79.2) 56(84) bytes of data.
64 bytesfrom 192.168.79.2: icmp_seq=1 ttl=64 time=2.23 ms
64 bytesfrom 192.168.79.2: icmp_seq=4 ttl=64 time=0.044 ms
/*安装Apache服务httpd包*/
[root@LAMPServer]# rpm -ivhhttpd-2.2.3-6.el5.i386.rpm
warning:httpd-2.2.3-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...########################################### [100%]
package httpd-2.2.3-6.el5 is alreadyinstalled
/*启动Apache服务*/
[root@LAMPServer]# service httpd start
Startinghttpd:[OK]
/*安装MySQL服务及其相关软件包*/
[root@LAMPServer]# rpm -ivh mysql-5.0.22-2.1.i386.rpm mysql-server-5.0.22-2.1.i386.rpmphp-mysql-5.1.6-5.el5.i386.rpm perl-DBI-1.52-1.fc6.i386.rpmperl-DBD-MySQL-3.0007-1.fc6.i386.rpm php-pdo-5.1.6-5.el5.i386.rpm
warning:mysql-5.0.22-2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...###########################################[100%]
1:perl-DBI########################################### [ 17%]
2:mysql########################################### [ 33%]
3:perl-DBD-MySQL###########################################[ 50%]
4:php-pdo########################################### [ 67%]
5:mysql-server########################################### [ 83%]
6:php-mysql########################################### [100%]
/*启动MySQL服务*/
[root@LAMPServer]# service mysqld start
InitializingMySQL database:Installing all preparedtables
Fillhelp tables
To startmysqld at boot time you have to copy support-files/mysql.server
to theright place for your system
PLEASEREMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To doso, start the server, then issue the following commands:
/usr/bin/mysqladmin-u root password 'new-password'
/usr/bin/mysqladmin-u root -h LAMP password 'new-password'
See themanual for more instructions.
You canstart the MySQL daemon with:
cd /usr; /usr/bin/mysqld_safe &
You cantest the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cdsql-bench ; perl run-all-tests
Pleasereport any problems with the /usr/bin/mysqlbug script!
Thelatest information about MySQL is available on the web at
http://www.mysql.com
SupportMySQL by buying support/licenses at http://shop.mysql.com
[OK]
StartingMySQL:[OK]
/*设置MySQL用户密码*/
[root@LAMPServer]# mysqladmin -u root password 123456
/*安装PHP软件包*/
[root@LAMPServer]# rpm -ivh php-5.1.6-5.el5.i386.rpm php-cli-5.1.6-5.el5.i386.rpmphp-common-5.1.6-5.el5.i386.rpm
warning:php-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...########################################### [100%]
package php-common-5.1.6-5.el5 is alreadyinstalled
package php-cli-5.1.6-5.el5 is alreadyinstalled
package php-5.1.6-5.el5 is alreadyinstalled
/*至此服务安装及配置结束*/
/*设置以上所有服务为开机自动启动*/
[root@LAMPServer]# chkconfig --level 2345 named on
[root@LAMPServer]# chkconfig --level 2345 mysqld on
[root@LAMPServer]# chkconfig --level 2345 httpd on
最后编辑测试页面,测试一下即可。
[root@LAMPServer]# vim /var/www/html/index.php
phpinfo();
?>
自带DNS服务的LAMP平台搭建圆满完成!好想给它起了个名字,叫LAMPD?还是DLAMP?(*^__^*)
唠唠闲话:
项目操作流程按照LAMP的顺序进行,方便新手阅读,也方便自己捋顺思路!
与人方便于己方便嘛~~
先到这里吧~~后续在接着数据库写写!