1、安裝gcc
yum -y install gcc
2、解壓檔案
tar -xvf httpd-2.2.21.tar.bz2
cd httpd-2.2.21
3、配置apache
./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared=all --enable-cache --enable-suexec --enable-disk-cache --enable-mem-cache --enable-authn-dbm=shared --enable-deflate=shared
4、編譯安裝
make
make install
5、如何把Apache加入到系統服務,用service指令來控制Apache的啟動和停止。
首先以apachectl腳本為模闆生成Apache服務控制腳本:
grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/apache
用vi編輯Apache服務控制腳本/etc/init.d/apache:
vi /etc/init.d/apache
在檔案最前面插入下面的行,使其支援chkconfig指令:
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server.
儲存後退出vi編輯器,執行下面的指令增加Apache服務控制腳本執行權限:
chmod +x /etc/init.d/apache
執行下面的指令将Apache服務加入到系統服務:
chkconfig --add apache
執行下面的指令檢查Apache服務是否已經生效:
chkconfig --list apache
指令輸出類似下面的結果:
apache 0:off 1:off 2:on 3:on 4:on 5:on 6:off
表明apache服務已經生效,在2、3、4、5運作級别随系統啟動而自動啟動,以後可以使用service指令控制Apache的啟動和停止。
啟動Apache服務:
service apache start
停止Apache服務:
service apache stop
執行下面的指令關閉開機自啟動:
chkconfig apache off
執行下面的指令改變開機自啟動的運作級别為3、5:
chkconfig --level 35 apache on
二、安裝mysql
1、解壓檔案
tar -xvf mysql-5.1.55
2、安裝必要元件
安裝ncurses否則會出現下面報錯
checking for termcap functions library... configure: error: No curses/termcap library found
yum安裝
yum -y install ncurses*
編譯安裝ncurses-5.6.tar.gz,
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure –prefix=/usr –with-shared –without-debug
3、配置mysql
./configure --prefix=/usr/local/mysql --with-big-tables --without-debug --with-pthread --enable-thread-safe-client --enable-assembler --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-charsers=gbk,gb2312,utf8 --with-extra-charsets=all --with-unix-socket-path=/tmp/mysql.sock --localstatedir=$Install_Dir/mysql/var/lib/mysql
5、權限設定以及初始mysql
增加mysql使用者以及組,配置設定權限
groupadd mysql
useradd -g mysql mysql
chmod +w /usr/local/mysql/
chown -R mysql:mysql /usr/local/mysql/
複制配置檔案,初始資料庫
cp support-files/my-medium.cnf /etc/my.cnf
./mysql_install_db --user=mysql
6、增加系統啟動以及service啟動
cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
service mysqld restart
三、安裝PHP
1、解壓安裝包
tar -xvf php-5.3.8
2、安裝元件支援
yum -y install bzip2-devel
yum -y install curl-devel
yum -y install gmp-devel
yum -y install aspell-devel
yum -y install libmcrypt-devel
yum -y install libjpeg-devel
yum -y install libpng-devel
yum -y install freetype-devel
yum -y install libxml2-devel
yum -y install libxslt-devel
安裝gd庫
tar -xvf GD_2_0_33.tar.gz
./configure
3、配置PHP
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl --with-bz2 --with-freetype-dir --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-xmlrpc --enable-zip --with-libxml-dir=/usr --enable-xml --enable-shmop --with-jpeg-dir --with-gd --with-png-dir --with-pspell --enable-ftp --with-zlib --enable-exif--with-gmp --enable-sysvmsg --enable-sockets --enable-wddx --with-gettext --with-mcrypt --with-xsl --with-mime-magic=/usr/share/file/magic.mime --enable-magic-quotes --with-pear --with-pdo-mysql --enable-mbstring --with-curlwrappers --enable-gd-native-ttf --enable-zend-multibyte --with-mhash --enable-calendar
make
注:出現報錯
checking for mysql_config... not found
configure: error: Unable to find your mysql installationg
執行下面操作
cp /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
5.修改配置檔案
cp php.ini-production /usr/local/php/etc/php.ini
修改php.ini
date.timezone = Asia/Shanghai
查找safe_mode=Off,更改為safe_mode=On
(1)查找max_execution_time= 30,更改為max_execution_time= 600
(2)查找max_input_time = 60,更改為max_input_time = 600
(3)查找memory_limit = 8M,更改為memory_limit = 20M
(4)查找display_errors = On,更改為display_errors = Off
(5)查找register_globals = Off,更改為register_globals = On
(6)查找post_max_size = 8M,更改為post_max_size = 20M
(7)查找upload_max_filesize = 2M,更改為upload_max_filesize = 20M
(8)查找session.auto_start = 0,更改為session.auto_start = 1
修改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.php
四、安裝eaccelerator
1、解壓
tar -xvf eaccelerator-0.9.6.1.tar.bz2
2、生成configure
cd eaccelerator-0.9.6.1
yum install autoconf
/usr/local/php/bin/phpize
3、配置
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
4、安裝
make
5、添加到php.ini
編譯安裝後我們會看到螢幕提示的eaccelerator.so所在的目錄,記住這個路徑,待會要用到。
在php.ini中添加以下内容
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-zts-20090626/eaccelerator.so"(上面的路徑+子產品名稱)
eaccelerator.shm_size="32"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
6、建立緩存檔案賦予權限
mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator/
7、重新開機apache,檢視php.ini是否生效
service apache restart
firefox 127.0.0.1/index.php
存在以下字段說明已經生效
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
相關說明
eaccelerator是php的加速軟體,使用後php的執行效率會有較大幅度的提升