一、apache的搭建
yum erase httpd
1、查看是否包含gcc软件包
yum -y install openssl-devel gcc gcc-c++
yum -y install gcc*
rpm -q gcc
cd /usr/local/src
tar zxvf httpd-2.2.9
cd http-2.2.9
藏和伪装apache的版本:
vim include/ap_release.h +44
将:
#define AP_SERVER_BASEPRODUCT "Apache"
修改为:
#define AP_SERVER_BASEPRODUCT "Microsoft-IIS/6.0"
另外修改这些选项:
#define AP_SERVER_BASEVENDOR “Apache Software Foundation”
#define AP_SERVER_BASEPROJECT “Apache HTTP Server”
#define AP_SERVER_BASEPRODUCT “Apache”
#define AP_SERVER_MAJORVERSION_NUMBER 2
#define AP_SERVER_MINORVERSION_NUMBER 2
#define AP_SERVER_PATCHLEVEL_NUMBER 15
#define AP_SERVER_DEVBUILD_BOOLEAN 0
"Copyright 2003 The Microsoft-IIS/6.0 Software Foundation."
vim os/unix/os.h +35
将:
#define PLATFORM "Unix"
修改为:
#define PLATFORM "Win32"
(下面彩色部分为最新版的apache安装步骤)
[root@yahoo test]# tar -zxf apr-1.4.5.tar.gz
[root@yahoo apr-1.4.5]# ./configure --prefix=/usr/local/apr
[root@yahoo apr-1.4.5]#cd cd apr-1.4.5
[root@yahoo apr-1.4.5]# make
[root@yahoo apr-1.4.5]# make install
[root@localhost apr-1.4.5]# cd ..
[root@yahoo test]# tar -zxf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
[root@localhost apr-util-1.3.12]# cd ..
./configure --prefix=/usr/local/pcre-8.0 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre
make
make install
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre-7.8
##./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl 这个步骤不要了,用上面的步骤代替。
make
make install
vim /usr/local/apache2/conf/httpd.conf +41
添加如下项目:
Listen 80(在这行下面添加)
ServerSignature Off
ServerTokens Prod
vim /usr/local/apache2/conf/httpd.conf +98
#ServerName ,前面的井号去掉,否则报错。
cp -ra /usr/local/apache2/bin/apachectl /usr/local/sbin/ 快速启动服务
开机自动启动服务:
cp /usr/local/apache2/bin/apachectl /etc/init.d/
mv /etc/init.d/apachectl /etc/init.d/httpd 这个操作去掉不要了!!!
vim /etc/init.d/apachectl
在第一行#!/bin/sh下增加两行文字如下
# chkconfig: 35 70 30
# description: Apache
保存退出 : 以后httpd服务就叫apachectl,重启服务用命令 apachectl restart
chkconfig --level 35 apachectl on
二、mysql的搭建
cd /usr/local/src/
yum -y install gcc*
yum -y install ncurses-dev*
groupadd mysql
useradd -g mysql mysql
mkdir /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
tar zxvf mysql-5.1.55
cd mysql-5.1.55
./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql --with-charset=gbk --with-collation=gbk_chinese_ci --with-extra-charsets=complex
make
make install
/usr/local/mysql/bin/mysql_install_db
chown -R mysql:mysql /var/lib/mysql
cp -ra /usr/local/src/mysql-5.1.55/support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqld_safe &
/usr/local/mysql/bin/mysqladmin -u root -p password '123456'
登录mysql试试:
/usr/local/mysql/bin/mysql -u root -p
cp -ra /usr/local/mysql/bin/* /usr/local/sbin/ 快速启动服务
开机自动启动服务:
cp /usr/local/src/mysql-5.1.55/support-files/mysql.server /etc/rc.d/init.d/
mv /etc/init.d/mysql.server /etc/init.d/mysql
chmod u+x /etc/rc.d/init.d/mysql
chkconfig --level 35 mysql on
三、php包含gd库的搭建
1、以root身份登录Linux主机;(权限不够,给相应权限)
2、停止Web Server服务,如果使用的是Apache可以通过以下命令停止:
shell> /usr/local/apache2/bin/apachectl stop
3、卸载当前PHP(为了安全起见最好先更改目录名称):
rm -rf /usr/local/php
rm -rf /usr/local/Zend
vi /usr/local/apache2/conf/httpd.conf
找到LoadModule phpX_module modules/libphpX.so
其中X是PHP版本(4或者5)一行,并将此行删除,保存退出
4、下载安装GD库需要的相关安装包:
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1
mkdir /usr/local/jpeg6/bin/
mkdir -p /usr/local/jpeg6/bin/cjpeg
安裝jpeg-6b
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp -ra /usr/share/libtool/config.* /usr/local/src/jpeg-6b/
./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
make
make install
5、安裝 freetype
tar zxvf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure --prefix=/usr/local/freetype
make
make install
6、安裝 zlib
tar zxvf zlib-1.2.3.tar.gz
cd zlib
cd 1.2.3
./configure
make
make install
7、安裝 libpng
tar zxvf libpng-1.2.8-config.tar.gz
cd libpng-1.2.8-config
./configure --prefix=/usr/local/libpng
make
make install
8、下载安装GD库安装包:
cd /usr/local/src
tar xzvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng --with-zlib --with-freetype=/usr/local/modules/freetype
make
make install
yum install php-gd gd :不做这步操作
8.1、安装cURL
cd /usr/local/src
tar zxvf curl-7.17.1.tar.gz
cd curl-7.17.1
./configure --prefix=/usr/local/curl
make
make install
9、下载PHP 5.3.5:
首先
yum -y install libxml*
yum -y install bzip*
yum -y install libpng*
cd /usr/local/src
tar xzvf php-5.3.5.tar.gz
cd php-5.3.5
./configure --prefix=/usr/local/php5 --with-curl=/usr/local/curl --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-zlib-dir --with-bz2 --with-tiff-dir --with-libxml-dir --with-freetype-dir=/usr/local/freetype/ --with-gd --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir --with-ttf --enable-mbstring --disable-ipv6 --enable-trace-vars
make
(如果不好用,去掉=/usr/local/gd/就行了!)
make install
cp -ra /usr/local/src/php-5.3.5/php.ini-production /usr/local/php5/lib/php.ini
安装并重新启动Apache服务后,可以创建phpinfo.php文件检查GD库的支持情况
vim /usr/local/apache2/htdocs/index.php
10、经测试,现在已经好用了,但是我在加几个步骤:
vim /usr/local/php5/lib/php.ini
把#号去掉: extension=msql.so
保存退出。
***********这些步骤去掉,不要了************
vim /usr/local/apache2/conf/httpd.conf
找到: LoadModule php5_module modules/libphp5.so
在下面加入:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改: DirectoryIndex index.html
为: DirectoryIndex index.php index.phps index.html
保存退出
vim /usr/local/php5/lib/php.ini +431
修改:
expose_php = On
为:
expose_php = Off
vim /usr/local/apache2/conf/httpd.conf +101
修改为:ServerName localhost:80
/usr/local/apache2/bin/apachectl restart
11、如果还不行,就在/usr/local/php5/php.ini文件中找到db的相关字,把前面的#去掉。
3、1测试php连接mysql
vim /usr/local/apache2/htdocs/mysql.php
$link=mysql_connect("localhost","root","123456");
if(!$link) echo "FAILD!";
else echo "OK!";
?>
vim /usr/local/apache2/htdocs/index.php
yum erase httpd
12、重启服务器:
/usr/local/apache2/bin/apachectl restart
/etc/init.d/mysql restart
cp -ra /usr/local/apache2/bin/apachectl /etc/init.d/ 前面做了,这两步就不用做了!!!
mv /etc/init.d/apachectl /etc/init.d/httpd
4、phpmyadmin的搭建
tar zxvf phpmyadmin-3.3.5
cp phpmyadmin-3.3.5 /usr/local/apach2/htdocs/
mv phpmyadmin-3.3.5 phpmyadmin
即可访问
阅读(1502) | 评论(0) | 转发(0) |