Red Hat Enterprise Linux 4+Apache2.2+PHP5.2+MYSQL5.0+Memcache+eAccelerator

来源:互联网 发布:林珊珊sunny的淘宝店 编辑:程序博客网 时间:2024/05/01 23:36

开始搭建


安装LINUX
1. 导航界面 【回车】
2. 是否将CD数据拷贝到磁盘上安装 【跳过】
3. LINUX安装界面 【下一步】
4. 选择语言 【英文】
5. 键盘 【美国标准键盘】
6. 选择类型 【自定义】
7. 磁盘分配 【自动分区】
8. 自动分区 【删除所有分区】
9. 引导装载 【下一步】
10. 网络配置 【DHCP】
11. 选择系统默认语言 【英文】
12. 选择时区 【北京】
13. 设置管理员密码 【321321】
14. 选择安装包 LINUX开发工具,系统配置工具
15. 开始安装


网络配置
 Netconfig                          图形界面设置网络,重启network后生效。


 网络服务启动脚本
   /etc/init.d/network                从新启动才能生效
 扩展:# /etc/rc.d/init.d/network start     启动network
    # /etc/rc.d/init.d/network stop        停止network
    # /etc/rc.d/init.d/network restart     重启network

 # ifconfig eth0 down               停止eth0接口
 # ifconfig eth0 up                   开启eth0接口

 Ifdown 网络接口名称                停止某个网络接口。
 Ifup  网络接口名称                   开启某个网络接口。


设置Ip
netcofnig
/etc/rc.d/init.d/network start
ifconfig eth0 up

设置防火墙
vi /etc/sysconfig/iptables
重启防火墙
/etc/init.d/iptables restart
查看防火墙
/etc/init.d/iptables status

 

创建目录
Mkdir /home/soft/
wget http://memcached.googlecode.com/files/memcached-1.2.7.tar.gz
wget http://apache.etoak.com/httpd/httpd-2.2.11.tar.gz
wget http://www.zlib.net/zlib-1.2.3.tar.gz
wget http://jaist.dl.sourceforge.net/sourceforge/libpng/libpng-1.4.0beta53.tar.gz
wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.1.10.tar.gz
wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz
wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
wget http://cn2.php.net/get/php-5.2.9.tar.gz/from/cn.php.net/mirror

 

安装Mysql5.0.37

开始安装和编译代码:
groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.0.37.tar.gz
cd mysql-5.0.37
./configure --prefix=/usr/local/webserver/mysql
make
make install
scripts/mysql_install_db
chown -R root:mysql /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql/var
chgrp -R mysql /usr/local/webserver/mysql
cp support-files/my-medium.cnf /etc/my.cnf
cp /usr/local/webserver/mysql/share/mysql/mysql.server /usr/local/webserver/mysql/share/mysql/mysqld
chmod a+x /usr/local/webserver/mysql/share/mysql/mysqld
mysqladmin -uroot password "321321"
启动服务方法
/usr/local/webserver/mysql/share/mysql/mysqld start
停止服务方法
/usr/local/webserver/mysql/bin/mysqladmin shutdown

cp /usr/local/webserver/mysql/include/mysql/mysql.h /usr/local/webserver/mysql/

设置成开机自启动
在/etc/rc.d/rc.local文件中加入一行
/usr/local/webserver/mysql/share/mysql/mysqld start
这样每次重新启动系统以后,mysql也会随系统一起启动.


安装APACHE


tar zxvf httpd-2.2.11.tar.gz
cd httpd-2.2.11
./configure --prefix=/usr/local/webserver/apache --with-mysql=/usr/local/webserver/mysql --enable-track-vars --enable-cgi --enable-so --enable-mods-shared=all --with-config-file-path=/usr/local/webserver/apache/conf
make && make install
cd ../

设置成开机自启动
在/etc/rc.d/rc.local文件中加入一行
/usr/local/webserver/apache/bin/apachectl start
这样每次重新启动系统以后,apache也会随系统一起启动.

--prefix=/usr/local/apache 指定把apahce安装到/usr/local/apache目录中;
--enable-cgi 支持CGI;
--with-config-file-path=/usr/local/apache/conf 指定把apache的配制文件放在/usr/local/apache/conf中;比如httpd.conf配制文件就在这个目录中;
--enable-track-vars 为启动cookie的get/post等追踪功能
--enable-so DSO功能
--enable-mods-shared=all 包含所有的模块为DSO

如果需要更多的选项,可能通过下面的命令来查看; (./configure --help)


安装Memcache + libevent

tar zxvf libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable
./configure --prefix=/usr/ && make && make install
cd ..
tar zxvf memcached-1.2.7.tar.gz
cd memcached-1.2.7
./configure --prefix=/usr/local/server/memcached --with-libevent=/usr/ && make && make install
/usr/local/server/memcached/bin/memcached -l 192.168.8.1 -d -p 10000 -u nobody -m 128
cd ../
 


表示用 daemon 的方式启动 memcached,监听在 192.168.8.1 的 10000 端口上,运行用户为 nobody,为其分配128MB 的内存


安装 PHP扩展包
 
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
cd ../

tar zxvf libpng-1.4.0beta53.tar.gz
cd libpng-1.4.0beta53
cd scripts/
mv makefile.linux ../makefile
cd ../
make
make install
cd ../

tar zxvf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure
make && make install
cd ../

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --enable-shared
make
make test
mkdir /usr/local/man
mkdir /usr/local/man/man1
make install
cd ../

tar zxvf gettext-0.17.tar.gz
cd gettext-0.17
./configure --prefix=/usr
cp /usr/lib/libattr.* /lib/
make
make install
cd ../

tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --with-png --with-freetype --with-jpeg
make && make install
cp gd.h  /usr/
cd ../

tar zxvf libiconv-1.12.tar.gz
cd libiconv-1.12
./configure --prefix=/usr/local/iconv
make
make install
cd ../

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

tar zxvf mhash-0.9.9.tar.gz
cd mhash-0.9.9
./configure
make
make install
cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
 
安装PHP
 
tar zxvf php-5.2.9.tar.gz
cd php-5.2.9
./configure --prefix=/usr/local/webserver/php --with-mysql=/usr/local/webserver/mysql --with-apxs2=/usr/local/webserver/apache/bin/apxs --with-freetype --with-png --with-gd --with-jpeg --with-zlib --enable-magic-quotes --with-iconv --without-sqlite --with-mcrypt --with-iconv=/usr/local/iconv --without-pdo-sqlite --with-gettext=/usr --with-mhash --enable-pcntl --enable-sockets --with-config-file-path=/usr/local/webserver/php/etc --disable-dom --disable-simplexml --enable-roxen-zts
make && make install

cp php.ini-dist /usr/local/webserver/php/etc/php.ini

vi /usr/local/webserver/apache/conf/httpd.conf

查找AddType application/x-tar .tgz 行,在下面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps

找到下面一行在后面加上index.php,这表示网站的默认页也能够为index.php

DirectoryIndex index.html index.html.var index.php

编译安装PHP5扩展模块

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../

tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../

tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
cd ../

配置eAccelerator加速PHP
mkdir -p /usr/local/webserver/eaccelerator_cache

修改PHP.ini
vi /usr/local/webserver/php/etc/php.ini

手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
  修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
  并在此行后增加以下几行,然后保存:
  extension = "memcache.so"
  extension = "pdo_mysql.so"

  再查找output_buffering = Off
  修改为output_buffering = On
按shift+g键跳到配置文件的最末尾,加上以下配置信息:
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

修改配置文件
vi /etc/sysctl.conf
输入以下内容
kernel.shmmax = 134217728
然后执行以下命令使配置生效
/sbin/sysctl -p