一缩多、準(zhǔn)備工作
1友浸、安裝編譯工具
gcc峰尝、gcc-c++、make
注意解決依賴關(guān)系收恢,推薦使用yum安裝武学,若不能聯(lián)網(wǎng)可使用安裝光盤做為yum
源——
1)編輯
yum
配置文件:
Mount /dev/cdrom /media
vi /etc/yum.repos.d/CentOS-Media.repo
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media *修改為光盤掛載點(diǎn)
enabled=1 *改為1意為啟用
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
2)設(shè)置alias值:
Vi /etc/bashrc
alias yum="yum --disablerepo=* --enablerepo=c5-media"
3)依次安裝gcc祭往、gcc-c++
Yum -y install gcc*
2、卸載系統(tǒng)
Apache火窒、MySQL和PHP的RPM安裝包
下載前需關(guān)閉啟動的服務(wù)硼补,如httpd、mysqld
service httpd stop
service mysqld stop
卸載RPM包的Apache熏矿、MySQL已骇、PHP
yum remove httpd
yum remove mysql
建議使用rpm –e http-1.2.3.rpm --nodeps (截斷這個rpm包的依賴性)
3、關(guān)閉SELinux票编,允許防火墻80端口訪問
1)關(guān)閉
SELinux
vi /etc/selinux/config
SELINUX=disabled *若安裝時沒有禁用SELinux褪储,將enforcing改為disabled
**修改后需重新啟動Linux方可生效!******
2)關(guān)閉防火墻
Netfilter/iptables
因尚未做防火墻講解慧域,直接簡單的關(guān)閉所有防火墻設(shè)置:
iptables -F *如果沒有禁用防火墻鲤竹,默認(rèn)80端口禁止訪問
service iptables save 防火墻策略寫到/etc/sysconfig/iptables,以后計算機(jī)重啟再加載這個文件時,防火墻策略就會永久清空.
二昔榴、編譯安裝
*每個源碼包配置編譯安裝完成后辛藻,確認(rèn)安裝目錄下是否生成安裝文件
安裝
libxml2
cd /lamp/libxml2-2.6.30
./configure --prefix=/usr/local/libxml2/
make
make install
安裝
libmcrypt
cd /lamp/libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt/
make
make install
*需調(diào)用gcc-c++編譯器,未安裝會報錯
安裝libltdl论泛,也在libmcrypt源碼目錄中揩尸,非新軟件
cd /lamp/libmcrypt-2.5.8/libltdl
./configure --enable-ltdl-install
make
make install
安裝zlib
cd /lamp/zlib-1.2.3
./configure
make
make install
- zlib指定安裝目錄可能造成libpng安裝失敗蛹屿,故不指定屁奏,為卸載方便,建議make install執(zhí)行結(jié)果輸出到安裝日志文件错负,便于日后卸載
安裝libpng
cd /lamp/libpng-1.2.31
./configure --prefix=/usr/local/libpng/
make
make install
安裝jpeg6
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1
cd /lamp/jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
- --enable-shared與--enable-static參數(shù)分別為建立共享庫和靜態(tài)庫使用的libtool
安裝freetype
cd /lamp/freetype-2.3.5
./configure --prefix=/usr/local/freetype/
make
make install
安裝autoconf
cd /lamp/autoconf-2.61
./configure
make
make install
安裝GD庫
mkdir /usr/local/gd2
cd /lamp/gd-2.0.35
png錯誤坟瓢,修改方法:
vi gd_png.c
把#include“png.h”替換#include "/usr/local/libpng/include/png.h"
./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/
--with-png=/usr/local/libpng/
Make
如果出現(xiàn)錯誤,把上面的兩步重新執(zhí)行一次.
make install
*若前面配置zlib時沒有指定安裝目錄犹撒,gd配置時不要添加--with-zlib=/usr/local/zlib/參數(shù)
安裝
Apache
cd /lamp/httpd-2.2.9
./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc/ --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared
make
make install
啟動Apache
測試:
/usr/local/apache2/bin/apachectl restart
查看進(jìn)程:
ps -le | grep httpd
查看apache
模塊
:
/usr/local/apache2/bin/apachectl –h
share 動態(tài)模塊或動態(tài)庫文件
Php5 rewrite
static 靜態(tài)模塊或表態(tài)庫文件
Server-status
Userdir
Virtual host
測試:
http://192.168.255.1/index.html
“it works”
設(shè)置Apache
隨機(jī)啟動
Vi /etc/rc.local
/usr/local/apache2/bin/apachectl restart
安裝ncurses
1.yum –y install ncurses*
2.源代碼編譯:
cd /lamp/ncurses-5.6
./configure --with-shared --without-debug --without-ada --enable-overwrite
make
make install
*若不安裝ncurses編譯MySQL時會報錯
- --without-ada參數(shù)為設(shè)定不編譯為ada綁定折联,因進(jìn)入chroot環(huán)境不能使ada;
--enable-overwrite參數(shù)為定義把頭文件安裝到/tools/include下而不是/tools/include/ncurses目錄
安裝MySQL
cd /lamp/mysql-5.0.41
./configure --prefix=/usr/local/mysql --without-debug --enable-thread-safe-client --with-pthread --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=/tmp/mysql.sock
make
make install
- --with-extra-charsets=all參數(shù)為安裝所有字符集
如果不行的話,make clean后再make ;make install,這樣去試一下,默認(rèn)是不支持innodb存儲引擎的.
其中--with-plugins=all可以把innodb加載進(jìn)來.
useradd mysql
*添加用戶組mysql识颊,將mysql用戶默認(rèn)組設(shè)置為mysql用戶組
1.cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
修改mysql配置文件
1.[client]
default-character-set=utf8
客戶端字符集
連接字符集
2.[ mysqld]
character-set-server = utf8
服務(wù)器字符集
數(shù)據(jù)庫字符集
collation-server = utf8_general_ci
服務(wù)器诚镰,庫,表的校驗字符集
default-storage-engine=innodb
把默認(rèn)的表引擎改為innodb
*生成MySQL配置文件
Setfacl –m u:mysql:rwx –R /usr/local/mysql
Setfacl –m d:u:mysql:rwx –R /usr/local/mysql
*用acl來讓mysql用戶對/usr/local/mysql有所有權(quán)限
/usr/local/mysql/bin/mysql_install_db --user=mysql
*創(chuàng)建數(shù)據(jù)庫授權(quán)表
啟動MySQL服務(wù)
1.用原本源代碼的方式去使用和啟動mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &
2.重啟以后還要生效:
Vi /etc/rc.local
/usr/local/mysql/bin/mysqld_safe --user=mysql &>/dev/null &
4./usr/local/mysql/bin/mysqladmin -uroot password kkk
給mysql用戶root加密碼.密碼為kkk
/usr/local/mysql/bin/mysql -u root -pkkk test
mysql>show databases;
mysql>use test
mysql>show tables;
進(jìn)入mysql以后用set來改密碼.
mysql> exit
登錄MySQL
客戶端控制臺設(shè)置指定
root
密碼
安裝PHP
編譯前確保系統(tǒng)已經(jīng)安裝了libtool和libtool-ltdl軟件包祥款,若沒有安裝使用
yum或rpm安裝下:
yum –y install libtool*
cd /lamp/php-5.2.6
./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
*若前面配置
zlib
時沒有指定安裝目錄清笨,
PHP
配置時不要添加
--with-zlib-dir=/usr/local/zlib/參數(shù)
make
make install
生成php.ini(php的配置文件)
cp /lamp/php-5.2.6/php.ini-dist /usr/local/php/etc/php.ini
測試apache與php的連通性,看apache是否能解析php文件
讓apache支持php代碼 :
vi /usr/local/apache2/etc/httpd.conf
AddType application/x-httpd-php .php
重啟Apache
服務(wù):
/usr/local/apache2/bin/apachectl restart
測試:vi
/usr/local/apache2/htdocs/test.php
<?php
phpinfo();
?>
通過瀏覽器測試:
編譯安裝memcache
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config –enable-memcache
make && make install
編譯安裝PDO_MYSQL
tar zxvf /lamp/PDO_MYSQL-1.0.2.tgz
cd /lamp/PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make && make install
修改php.ini
extension_dir = "/usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/"
extension="memcache.so";
extension="pdo_mysql.so";
修改php文件生效:
/usr/local/apache2/bin/apachectl restart
安裝Zend加速器
cd /lamp/ZendOptimizer-3.2.6-linux-glibc21-i386
./install.sh
安裝
memcache
源代碼
http://memcached.googlecode.com/files/memcached-1.4.10.tar.gz
首先安裝依賴包libevent
Yum –y install libevent*
主包已經(jīng)安裝,別忘記安裝libevent-devel*,不然./configure過不去
Tar xzf /lamp/memcached-1.4.10.tar.gz
Cd /lamp/memcached-1.4.10
./configure --prefix=/usr/local/memcache
Make && make install
Useradd memcache
因為系統(tǒng)不能用root運(yùn)行memcache軟件
/usr/local/memcache/bin/memcached –umemcache & #后臺運(yùn)行
Netstat –tunpl|grep :11211
telnet 192.168.10.1 11211
stats
寫入自啟動:
Vi /etc/rc.local
/usr/local/memcache/bin/memcached –umemcache &
如何殺掉后臺進(jìn)程,用kill %1,查看進(jìn)程用jobs
安裝
brocms
源碼
主要是為了測試lamp
環(huán)境編譯是否成功
,
主要測試以下幾個地方
:
pdo
pdo-mysql
memcache
要注意memcache,因為它有兩個源代碼包刃跛,一個是php驅(qū)動庫包
(memcache-2.2.5.tgz),另一個是memcache主程序源代碼包(memcached-1.4.10.tar.gz);