
作者:silverwolf 本文参考tian1118,trotter的文章修改而成,使用的源码包版本如下: mysql-standard-4.0.25-pc-linux-gnu-i686.tar.gz httpd-2.0.54.tar.gz php-4.4.0.tar.gz 可到www.mysql.com , www.apache.org , www.php.net下载
一、安装mysql cp mysql-standard-4.0.25-pc-linux-gnu-i686.tar.gz /usr/local/ tar -zxvf mysql-standard-4.0.25-pc-linux-gnu-i686.tar.gz cd mysql-standard-4.0.25-pc-linux-gnu-i686/ vi INSTALL-BINARY 获得安装信息
groupadd mysql useradd -g mysql mysql cd /usr/local/ mv mysql-standard-4.0.25-pc-linux-gnu-i686 mysql 安装文档该步骤为建立软链接 ./scripts/mysql_install_db --user=mysql chown -R root . chown -R mysql data chgrp -R mysql .
./bin/mysqld_safe --user=mysql & 从后台启动mysql,这时会看到 [1] 3879 [root--1014--/usr/local/mysql]Starting mysqld daemon with databases from /usr/local/mysql/data 证实已成功,能够用ps -aux │ grep mysql 能够看到。
测试: /usr/local/mysql/bin/mysql mysql>show database; mysql>exit;
mysqladmin -uroot -p ’您的旧密码’(默认为空) ’您的新密码’
二、安装apache
tar -zxvf httpd-2.0.54.tar.gz cd httpd-2.0.54 vi INSTALL 获得一些安装信息
mkdir /usr/local/apache2 ./configure --perfix=/usr/local/apache2 --enable-module=so make ; make install cd /usr/local/apache2/bin
cd /usr/loca/apache2/conf/ 查找#ServerName www.example.com:80 改为ServerName 127.0.0.1:80 ./apachectl start httpd: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName 测试:打开浏览器,在地址栏输入127.0.0.1或您的电脑名,假如能够看到漂亮的羽毛,证实apache安装成功。
三、安装php
tar -zxvf php-4.4.0.tar.gz cd php-4.4.0 vi INSTALL 获得一些安装信息
mkdir /usr/local/php4 ./configure --prefix=/usr/local/php4 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql 假如出现如下证实快成功了。
+--------------------------------------------------------------------+ │ License: │ │ This software is subject to the PHP License, available in this │ │ distribution in the file LICENSE. By continuing this installation │ │ process, you are bound by the terms of this license agreement. │ │ If you do not agree with the terms of this license, you must abort │ │ the installation process at this point. │ +--------------------------------------------------------------------+ Thank you for using PHP. make make install
四、php和apache整合 vi /usr/local/apache2/conf/httpd.conf 找到DirectoryIndex改为如下: DirectoryIndex index.html index.php index.htm index.html.var
找到 AddType application/x-compress .Z AddType application/x-gzip .gz .tgz 在他后面添加,增加PHP支持模组 AddType application/x-httpd-php .php /usr/local/apache2/bin/apachectl restart
测试: vi /usr/local/apache2/htdocs/index.php 添加 ,保存退出 打开浏览器,输入 http://127.0.0.1/index.php 假如能够看到关于php的信息,证实php安装成功。
五、安装phpBB /usr/local/mysql/bin/mysql -u root -p ’您的密码’ mysql>create database myphpbb; Query OK, 1 row affected (0.02 sec) 好了.记住您为phpbb起的数据库名,以后要用的.myphpbb
到www.phpbb.com下载软件包 lang_chinese_simplified.tar.gz phpbb的源码包 phpBB-2.0.12.tar.gz 中文支持 subSilver_chinese_simplified.tar.gz 中文支持
cp phpBB-2.0.12.tar.gz /usr/local/apache2/htdocs cd /usr/local/apache2/htdocs tar -zxvf phpBB-2.0.12.tar.gz
tar -zxvf lang_chinese_simplified.tar.gz tar -zxvf subSilver_chinese_simplified.tar.gz
cp -r lang_chinese_simplified/ ./phpBB2/language/ cp -r subSilver/ ./phpBB2/templates/ chmod 777 phpBB2/config.php cd ../bin/
./apachectl start 启动apache 在浏览器中输入http://localhost/phpBB2/install/install.php 进入phpbb的安装界面.这里有许多需要填写的信息。
我写出自己填写的信息以供参考. 预设论坛语言: Chinese 数据库格式: MySQL4.x 请选择安装模式: 完整安装 数据库设定 数据库服务器主机名称: localhost 您的数据库名称: myphpbb 数据库用户帐号: root 数据库密码: 您新配置的密码(默认为空) 数据库的表格字首 (Prefix): phpbb_ 系统管理员设定 论坛管理员电子邮件信箱: ***@*** 域名: 服务端口: 80 脚本路径: /phpBB2/ 系统管理员帐号名称: administrator 系统管理员密码: **** 系统管理员密码 [ 确认 ]: **** 这时安装成功,系统会提示您在删除phpBB2目录中的install/ contrib/以确保安全
六、相关安全设定 (1).阻止您的系统响应任何从外部/内部来的ping请求 #vi /etc/rc.d/rc.local echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
(2).减少系统CPU占有量和由于误操作导致系统重启 #vi /etc/inittab id:3:initdefault: # Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 #3:2345:respawn:/sbin/mingetty tty3 #4:2345:respawn:/sbin/mingetty tty4 #5:2345:respawn:/sbin/mingetty tty5 #6:2345:respawn:/sbin/mingetty tty6 #ca::ctrlaltdel:/sbin/shutdown -t3 -r now 保存并退出
(3). 删除不必要的拥护和组 #userdel -r username adm,lp,sync,shutdown,halt,mail,procmail,mailx,news,uucp,operator,games,gopher,ftp
#groupdel groupname adm,lp,sync,shutdown,halt,mail,procmail,mailx,news,uucp,operator,games,gopher,ftp
(4). 创建ftp账户 #groupadd su #useradd -g su -d /usr/local/apache/htdocs webserver
(5). 用chattr命令给下面的文档加上不可更改属性。 [root@deep]# chattr +i /etc/passwd [root@deep]# chattr +i /etc/shadow [root@deep]# chattr +i /etc/group [root@deep]# chattr +i /etc/gshadow
(6).禁止任何人(非法)通过su命令改变为root用户 #vi /etc/pam.d/su auth sufficient /lib/security/pam_rootok.so debug auth required /lib/security/pam_wheel.so group=sul
保存并退出 这样之后,只有su组成员能够改变为root用户
(7).资源限制防止DoS类型攻击 #vi /etc/security/limits.conf 在这个文档后加入下面 * hard core 0 * hard rss 5000 * hard nproc 20 保存并退出
#vi /etc/pam.d/login 在这个文档后加入下面 session required /lib/security/pam_limits.so 保存并退出
(8).修改Apache的版本 httpd.conf里面,修改配置项. ServerSignature Off ServerTokens Prod 或编译前修改相关定义文档 include/ap_release.h AP_SERVER_MAJORVERSION主版本号 AP_SERVER_MINORVERSION次版本号 AP_SERVER_PATCHLEVEL最次版本号 七、创建MySQL、Apache自启动 #vi /etc/rc.d/rc.local /usr/local/mysql/bin/mysqld_safe --user=mysql & /usr/local/apache/bin/apachectl start
|