Centos6.0 x64下搭(dā)建LAMP環境
係統環境(jìng):Centos6.0 x64
1、確認(rèn)搭建LAMP所需(xū)要的環境是否已經安裝
[root@centos6 ~]# rpm -q make gcc gcc-c++ zlib-devel libaio
備注:安(ān)裝libpng時候需要zlib-devel
安裝mysql時候需(xū)要libaio
2、如果(guǒ)沒安裝則yum安裝
[root@centos6 ~]# yum install make gcc gcc-c++ zlib-devel libaio -y
3、由(yóu)於要(yào)使用編譯安(ān)裝,所(suǒ)以查看(kàn)httpd、mysql、php是否安裝,如果安裝(zhuāng)則卸載(zǎi)
[root@centos6 ~]# rpm -q httpd mysql php
4、編譯安裝libxml2
注:libxml2是一個xml的c語(yǔ)言版的解析器,不僅(jǐn)支持(chí)c語言,還支持c++、php、Pascal、Ruby、Tcl等語言的(de)綁定
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libxml2-2.7.8.tar.gz
[root@centos6 LAMP]# cd ./libxml2-2.7.8
[root@centos6 libxml2-2.7.8]# ./configure --prefix=/usr/local/libxml2/
[root@centos6 libxml2-2.7.8]# make;make install
5、編譯(yì)安裝libmcrypt
注:libmcrypt是加密算法擴展庫。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等(děng)算法(fǎ)。
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@centos6 LAMP]# cd ./libmcrypt-2.5.8
[root@centos6 libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt/
[root@centos6 libmcrypt-2.5.8]# make;make install
6、編譯(yì)安裝zlib
注:zlib是(shì)提供數據(jù)壓縮用(yòng)的(de)函式(shì)庫
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf zlib-1.2.5.tar.gz
[root@centos6 LAMP]# cd ./zlib-1.2.5
[root@centos6 zlib-1.2.5]# ./configure --prefix=/usr/local/zlib/
[root@centos6 zlib-1.2.5]# make ; make install
7、編(biān)譯安(ān)裝libpng
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libpng-1.5.4.tar.gz
[root@centos6 LAMP]# cd ./libpng-1.5.4
[root@centos6 libpng-1.5.4]#
./configure --prefix=/usr/local/libpng/ --enable-shared
[root@centos6 libpng-1.5.4]# make ; make install
8、編譯安(ān)裝jpeg
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf jpegsrc.v8c.tar.gz
[root@centos6 LAMP]# cd ./jpeg-8c/
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/(創(chuàng)建jpeg軟(ruǎn)件的安裝目錄)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/bin/(創建(jiàn)存放命令的(de)目錄)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/lib/(創建jpeg庫文件所在目錄)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/include/(創建存放頭(tóu)文件目錄)
[root@centos6 jpeg-8c]# mkdir -p /usr/local/jpeg/man/man1(建立(lì)存(cún)放手(shǒu)冊的目錄)
[root@centos6 jpeg-8c]#
./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static(建立共(gòng)享庫使用的GNU的libtool和靜(jìng)態(tài)庫(kù)使(shǐ)用的GNU的libtool)
[root@centos6 jpeg-8c]# make ; make install
9、編譯安裝freetype
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf freetype-2.4.6.tar.gz
[root@centos6 LAMP]# cd ./freetype-2.4.6
[root@centos6 freetype-2.4.6]#
./configure --prefix=/usr/local/freetype/ --enable-shared
[root@centos6 freetype-2.4.6]# make ;make install
10、 編譯安裝autoconf
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf autoconf-2.68.tar.gz
[root@centos6 LAMP]# cd ./autoconf-2.68
[root@centos6 autoconf-2.68]# ./configure
[root@centos6 autoconf-2.68]# make ; make install
11、 編(biān)譯(yì)安裝(zhuāng)GD
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf gd-2.0.35.tar.gz
[root@centos6 LAMP]# cd ./gd-2.0.35
[root@centos6 gd-2.0.35]#
./configure --prefix=/usr/local/gd/ --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/
[root@centos6 gd-2.0.35]# make ; make install
12、 安裝apache
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf httpd-2.2.19.tar.gz
[root@centos6 LAMP]# cd ./httpd-2.2.19
[root@centos6 httpd-2.2.19]#
./configure --prefix=/usr/local/apache/ --enable-so --enable-rewrite
[root@centos6 httpd-2.2.19]# make ; make install
[root@centos6 LAMP]# /usr/local/apache/bin/apachectl start
[root@centos6 LAMP]#
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@centos6 LAMP]# chmod +x /etc/init.d/httpd
[root@centos6 ~]# chkconfig --add httpd
注意:如(rú)果(guǒ)提示service httpd does not support chkconfig錯誤
解決辦法:編輯/etc/rc.d/init.d/httpd在文件第二行(háng)加入
#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server
[root@centos6 ~]# chkconfig --level 2345 httpd on
[root@centos6 LAMP]# service httpd restart
開(kāi)機自動啟動apache的另(lìng)一種方法:
修改/etc/rc.local文(wén)件(jiàn)
# vim /etc/rc.local
在文件中(zhōng)添加(jiā)/usr/local/apache/bin/apachectl start
13、 編譯安裝mysql
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf mysql-5.5.15-linux2.6-x86_64.tar.gz
[root@centos6 LAMP]# cd ./mysql-5.5.15-linux2.6-x86_64
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# groupadd mysql
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# useradd -r -g mysql mysql(創建mysql用戶,並將用戶(hù)指定至mysql組(zǔ))
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# cd /usr/local/
[root@centos6 local]# ln -s /tmp/LAMP/mysql-5.5.15-linux2.6-x86_64 mysql
[root@centos6 local]# cd ./mysql/
[root@centos6 mysql]# chown -R mysql .(將該(gāi)目錄的用戶權(quán)限全部更改為mysql用戶)
[root@centos6 mysql]# chgrp -R mysql .(將該目錄的(de)用(yòng)戶(hù)組全部改(gǎi)為mysql用戶(hù)組(zǔ))
[root@centos6 mysql]# ./scripts/mysql_install_db --user=mysql(將mysql目(mù)錄(lù)的數據庫使(shǐ)用權(quán)限指定為mysql)
[root@centos6 mysql]# chown -R root .
[root@centos6 mysql]# chown -R mysql data
[root@centos6 mysql]# cp support-files/my-medium.cnf /etc/my.cnf(將當前(qián)目錄下的配置文(wén)件(jiàn)拷貝(bèi)到係統配置(zhì)文(wén)件下,並更名為(wéi)my.cnf)
[root@centos6 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@centos6 mysql]# chmod +x /etc/init.d/mysqld
[root@centos6 mysql]# chkconfig --add mysqld
[root@centos6 mysql]# chkconfig --level 345 mysqld on
[root@centos6 mysql]# service mysqld restart
[root@centos6 mysql]#
/usr/local/mysql/bin/mysqladmin -u root password '123456'(設置root用戶登(dēng)錄mysql的密碼)
[root@centos6 mysql]# /usr/local/mysql/bin/mysql -u root –p(進(jìn)入並訪問mysql數據(jù))
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.5.15-log MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>(成功登錄(lù)mysql)
14、 編譯(yì)安(ān)裝(zhuāng)php
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]#
關鍵詞:CentOS,LAMP
閱讀本(běn)文後您有什麽感(gǎn)想(xiǎng)? 已有 人給出(chū)評價!
- 0
- 0
- 0
- 0
- 0
- 0