您好,登錄后才能下訂單哦!
本文小編為大家詳細介紹“64位CentOS6.0下怎么搭建LAMP環境”,內容詳細,步驟清晰,細節處理妥當,希望這篇“64位CentOS6.0下怎么搭建LAMP環境”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。
1、確認搭建lamp所需要的環境是否已經安裝
[root@centos6 ~]# rpm -q make gcc gcc-c++ zlib-devel libaio
備注:安裝libpng時候需要zlib-devel
安裝mysql時候需要libaio
2、如果沒安裝則yum安裝
[root@centos6 ~]# yum install make gcc gcc-c++ zlib-devel libaio -y
3、由于要使用編譯安裝,所以查看httpd、mysql、php是否安裝,如果安裝則卸載
[root@centos6 ~]# rpm -q httpd mysql php
4、編譯安裝libxml2
注:libxml2是一個xml的c語言版的解析器,不僅支持c語言,還支持c++、php、pascal、ruby、tcl等語言的綁定
[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、編譯安裝libmcrypt
注:libmcrypt是加密算法擴展庫。支持des, 3des, rijndael, twofish, idea, gost, cast-256, arcfour, serpent, safer+等算法。
[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、編譯安裝zlib
注:zlib是提供數據壓縮用的函式庫
[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、編譯安裝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、編譯安裝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/(創建jpeg軟件的安裝目錄)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/bin/(創建存放命令的目錄)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/lib/(創建jpeg庫文件所在目錄)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/include/(創建存放頭文件目錄)
[root@centos6 jpeg-8c]# mkdir -p /usr/local/jpeg/man/man1(建立存放手冊的目錄)
[root@centos6 jpeg-8c]#
./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static(建立共享庫使用的gnu的libtool和靜態庫使用的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、 編譯安裝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
注意:如果提示service httpd does not support chkconfig錯誤
解決辦法:編輯/etc/rc.d/init.d/httpd在文件第二行加入
#chkconfig:2345 10 90
#description:activates/deactivates apache web server
[root@centos6 ~]# chkconfig --level 2345 httpd on
[root@centos6 lamp]# service httpd restart
開機自動啟動apache的另一種方法:
修改/etc/rc.local文件
# vim /etc/rc.local
在文件中添加/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用戶,并將用戶指定至mysql組)
[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 .(將該目錄的用戶權限全部更改為mysql用戶)
[root@centos6 mysql]# chgrp -r mysql .(將該目錄的用戶組全部改為mysql用戶組)
[root@centos6 mysql]# ./scripts/mysql_install_db --user=mysql(將mysql目錄的數據庫使用權限指定為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(將當前目錄下的配置文件拷貝到系統配置文件下,并更名為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用戶登錄mysql的密碼)
[root@centos6 mysql]# /usr/local/mysql/bin/mysql -u root –p(進入并訪問mysql數據)
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>(成功登錄mysql)
14、 編譯安裝php
[root@centos6 lamp]# pwd
/tmp/lamp
[root@centos6 lamp]# tar -zxvf php-5.3.7.tar.gz
[root@centos6 lamp]# cd ./php-5.3.7
[root@centos6 php-5.3.7]#
./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg/ --with-freetype-dir=/usr/local/freetype/--with-gd-dir=/usr/local/gd/--with-zlib-dir=/usr/local/zlib/--with-mcrypt=/usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
[root@centos6 php-5.3.7]# make ; make install
[root@centos6 php-5.3.7]#
cp php.ini-development /usr/local/php/lib/php.ini
#vim /usr/local/php/lib/php.ini
//這里需要將register_globals=off更改on模式,還有時間格式改為本地
15、 更改apache的配置文件,達到解析php文件的目的
[root@centos6 ~]# vim /usr/local/apache/conf/httpd.conf
addtype application/x-compress .z
addtype application/x-gzip .gz .tgz
addtype application/x-httpd-php .php .phtml
addtype application/x-httpd-php-source .phps
添加上面綠色內容,表示apache服務中可以解析php格式文件
接下來要檢查apache目錄下生成的php動態連接庫文件,在目錄/usr/local/apache/modules,找到是否存在 libphp5.so文件
16、 驗證
[root@centos6 ~]# vim /usr/local/apache/htdocs/index.php
添加內容為
<?php
echo phpinfo();
?>
讀到這里,這篇“64位CentOS6.0下怎么搭建LAMP環境”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。