RHEL5搭建apache服务器全过程(二)DNS服务器及LAMP平台
–>
1、在三台服务器上安装RHEL5操作系统(图形模式),分区规划如下:
/boot 200M
/swap 4G(根据实际物理内存而定)
/home 8G
/ 120G(根据实际物理硬盘而定)
禁用selinux,只在DNS服务器上启用iptables
分别修改各服务器主机名:
DNS服务器:dns.eyo.com
WebServer1:web1.eyo.com
WebServer2:web2.eyo.com
2、在dns.eyo.com上搭建DNS服务器
将www.eyo.com对内解析到192.168.0.225,对外解析到公司实际公网IP(依赖DNAT),需要安装的rpm包如下:
Ø bind-9.3.6
Ø bind-chroot-9.3.6
Ø caching-nameserver-9.3.6
Ø bind –utils-9.3.6
详细步骤如下:
[[email protected] ~]# mount /dev/cdrom /mnt/
[[email protected] ~]# cd /mnt/Server/
[[email protected] Server]# rpm -ivh bind-9.3.6-4.P1.el5.i386.rpm
[[email protected] Server]# rpm -ivh bind-chroot-9.3.6-4.P1.el5.i386.rpm
[[email protected] Server]# rpm -ivh bind-utils-9.3.6-4.P1.el5.i386.rpm
[[email protected] Server]# rpm -ivh caching-nameserver-9.3.6-4.P1.el5.i386.rpm
[[email protected] Server]# cd /var/named/chroot/etc/
[[email protected] etc]# cp -p named.caching-nameserver.conf named.conf
[[email protected] etc]# vim named.conf
options {
listen-on port 53 { 192.168.0.227; 173.16.16.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”;
// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
allow-query { any; };
allow-query-cache { localhost; };
};
view “LAN” {
match-clients { 192.168.0.0/24; };
zone “eyo.com” IN {
type master;
file “eyo.com.zone.lan”;
};
};
view “WAN” {
match-clients { any; };
zone “eyo.com” IN {
type master;
file “eyo.com.zone.wan”;
};
};
[[email protected] named]# named-checkconf /var/named/chroot/etc/named.conf
[[email protected] etc]# cd ../var/named/
[[email protected] named]# cp -p named.local eyo.com.zone.lan
[[email protected] named]# cp -p named.local eyo.com.zone.wan
[[email protected] named]# vim eyo.com.zone.lan
$TTL 86400
@ IN SOA ns1.eyo.com. root.eyo.com. (
2011070801; Serial
4H ; Refresh
30M ; Retry
12H ; Expire
1D ); Minimum
IN NS ns1.eyo.com.
ns1 IN A 192.168.0.227
www IN A 192.168.0.225
web1 IN A 192.168.0.223
web2 IN A 192.168.0.224
[[email protected] named]# vim eyo.com.zone.wan
$TTL 86400
@ IN SOA ns1.eyo.com. root.eyo.com. (
2011070801; Serial
4H ; Refresh
30M ; Retry
12H ; Expire
1D ) ; Minimum
IN NS ns1.eyo.com.
ns1 IN A 173.16.16.1
www IN A 173.16.16.1
[[email protected] named]# named-checkzone eyo.com eyo.com.zone.lan
zone eyo.com/IN: loaded serial 2011070801
OK
[[email protected] named]# named-checkzone eyo.com eyo.com.zone.wan
zone eyo.com/IN: loaded serial 2011070801
OK
[[email protected] named]# service named start
启动 named: [确定]
[[email protected] named]# chkconfig named on
3、在web1、web2服务器上搭建LAMP平台(暂时不安装awstats和phpMyAdmin)
编译安装Apache:
[[email protected] Desktop]# tar zxvf httpd-2.2.9.tar.gz -C /usr/src/
[[email protected] Desktop]# cd /usr/src/httpd-2.2.9/
[[email protected] httpd-2.2.9]# ./configure –prefix=/usr/local/apache2 –enable-so –enable-rewrite –enable-ssl –with-ssl=/usr/lib –enable-auth-digest –enable-cgi –enable-suexec –with-suexec-caller=daemon –with-suexec-docroot=/usr/local/apache2/htdocs
[[email protected] httpd-2.2.9]# make && make install
[[email protected] httpd-2.2.9]# vim /usr/local/apache2/conf/httpd.conf
97 ServerName web1.eyo.com(修改97行)
[[email protected] httpd-2.2.9]# echo “/usr/local/apache2/bin/apachectl start” >> /etc/rc.local
Apache服务器不需做太多配置,暂时告一段落
编译安装MySQL:
[[email protected] Desktop]# useradd -M -s /sbin/nologin mysql
[[email protected] Desktop]# tar zxvf mysql-5.0.56.tar.gz -C /usr/src/
[[email protected] Desktop]# cd /usr/src/mysql-5.0.56/
[[email protected] mysql-5.0.56]# ./configure –prefix=/usr/local/mysql
[[email protected] mysql-5.0.56]# make && make install
[[email protected] mysql-5.0.56]# cp support-files/my-medium.cnf /etc/my.cnf
[[email protected] mysql-5.0.56]# /usr/local/mysql/bin/mysql_install_db –user=mysql
[[email protected] mysql-5.0.56]# chown -R root:mysql /usr/local/mysql/
[[email protected] mysql-5.0.56]# chown -R mysql /usr/local/mysql/var/
[[email protected] mysql-5.0.56]# echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf
[[email protected] mysql-5.0.56]# ldconfig
[[email protected] mysql-5.0.56]# /usr/local/mysql/bin/mysqld_safe –user=mysql &
[1] 14639
Starting mysqld daemon with databases from /usr/local/mysql/var
[[email protected] mysql-5.0.56]# netstat -tunpl | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 14665/mysqld
[[email protected] mysql-5.0.56]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql-5.0.56]# chmod +x /etc/init.d/mysqld
[[email protected] mysql-5.0.56]# chkconfig –add mysqld
[[email protected] mysql-5.0.56]# chkconfig mysqld on
[[email protected] mysql-5.0.56]# export PATH=$PATH:/usr/local/mysql/bin
[[email protected] mysql-5.0.56]# echo “PATH=$PATH:/usr/local/mysql/bin” >> /etc/profile
[[email protected] ~]# mysqladmin -u root password “redhat”
构建PHP环境:
[[email protected] Desktop]# tar zxvf php-5.2.6.tar.gz -C /usr/src/
[[email protected] Desktop]# cd /usr/src/php-5.2.6/
[[email protected] php-5.2.6]# ./configure –prefix=/usr/local/php5 –enable-mbstring –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql –with-config-file-path=/usr/local/php5
[[email protected] php-5.2.6]# make && make install
[[email protected] php-5.2.6]# cp php.ini-dist /usr/local/php5/php.ini
[[email protected] php-5.2.6]# vim /usr/local/apache2/conf/httpd.conf
53 LoadModule php5_module modules/libphp5.so
166 <IfModule dir_module>
167 DirectoryIndex index.php index.html
168 </IfModule>
308 AddType application/x-compress .Z
309 AddType application/x-gzip .gz .tgz
310 AddType application/x-httpd-php .php
[[email protected] php-5.2.6]# /usr/local/apache2/bin/apachectl restart
测试PHP运行环境:
[[email protected] ~]# vim /usr/local/apache2/htdocs/test.php
<?php
phpinfo( );
?>
在浏览器中访问http://192.168.0.223/test.php进行测试,将出现如下界面:
[[email protected] ~]# vim /usr/local/apache2/htdocs/testdb.php
?php
$link=mysql_connect(‘localhost’,’test’,”);
if (! $link) echo “Fail”;
else echo “Success”;
mysql_close();
?>
在浏览器中访问http://192.168.0.223/testdb.php进行测试,将出现Success,如图:
注意:以上LAMP平台的步骤必须在web2上也进行一次!
转载于:https://blog.51cto.com/linuxclub/606341
本文来源 互联网收集,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源,如您发现有涉嫌抄袭侵权的内容,请联系本站核实处理。