LAMP安裝手冊
LAMP安裝手冊 :
一、主要軟件包
1. httpd-2.2.6.tar.gz
2. mysql-5.0.45-linux-i686-glibc23.tar.gz ( 這個版本是已編譯好的壓縮包,解壓后稍做配置即可使用 )
3. php-5.2.5.tar.gz
安裝 php 所需的軟件包(其中 libxml2 是安裝 php5 必須的 . )
1. libxml2-(version).tar.gz ---> http://ftp.gnome.org/pub/GNOME/sources/libxm2
2. libxslt-(version).tar.gz ---> http://ftp.gnome.org/pub/GNOME/sources/libxslt
3. curl-(version).tar.gz ---> http://curl.haxx.se/download
GD 庫所需要軟件包(有人說 PHP 源碼包里自帶了 GD2.0.28 和 zlib ,只要安裝 GD 的三個支持包: jpg,png 和 freetype ,但是我們還是下載)
1. gd-(version).tar.gz ---> http://www.libgd.org/Main_Page or http://www.libgd.org/releases/
2. freetype-(version).tar.gz ---> http://sourceforge.net/projects/freetype
3. jpegsrc.v6b.tar.gz ---> http://ijg.org/files/jpegsrc.v6b.tar.gz
4. libpng-(version).tar.gz ---> http://www.libpng.org/pub/png/libpng.html
5. zlib-1.2.3.tar.gz ---> http://www.zlib.net
把以上所有軟件包下載到: /root/Software/ 目錄下 .
#p#
二:安裝 mysql
- # tar -zvxf mysql-5.0.45-linux-i686-glibc23.tar.gz
- # mkdir -p /usr/local/mysql
- # cp -r mysql-5.0.45 /usr/local/mysql
- # cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql // 開機啟動 mysql
- # cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
添加 mysql 用戶及用戶組
- # groupadd mysql
- # useradd -g mysql mysql
修改 mysql 目錄權(quán)限
- # chown -R root /usr/local/mysql
- # chgrp -R mysql /usr/local/mysql
- # chown -R mysql /usr/local/mysql/data
生成 mysql 系統(tǒng)數(shù)據(jù)庫
- # /usr/local/mysql/scripts/mysql_install_db --user=mysql& // 啟動 mysql 服務(wù)
- # /usr/local/mysql/bin/mysqld_safe --user=mysql&
如出現(xiàn) Starting mysqld daemon with databases from /usr/local/mysql/data 代表正常啟動 mysql 服務(wù)了 .
按 Ctrl + C 跳出修改 mysql 的 root 密碼
- # /usr/local/mysql/bin/mysqladmin -u root -p password "123456"
#p#
三:安裝 GD 庫 ( 讓 PHP 支持 GIF,PNG,JPEG)
a. 安裝 jpeg6 建立目錄:
- # mkdir -p /usr/local/jpeg6
- # mkdir -p /usr/local/jpeg6/bin
- # mkdir -p /usr/local/jpeg6/lib
- # mkdir -p /usr/local/jpeg6/include
- # mkdir -p /usr/local/jpeg6/man
- # mkdir -p /usr/local/jpeg6/man1
- # mkdir -p /usr/local/jpeg6/man/man1
- # cd /root/Software/
- # tar -zvxf jpegsrc.v6b.tar.gz
- # cd jpeg6
- # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
- # make
- # make install
b.libpng 包 ( 支持 PNG)
- # cd /root/Software/
- # tar -zvxf libpng-(version).tar.gz
- # cd libpng-(version)
- # ./configure --prefix=/usr/local/libpng
- # make
- #> make install
c. 安裝 freetype
- # cd /root/Software/
- # tar -zvxf freetype-(version).tar.gz
- # cd freetype-(version)
- # mkdir -p /usr/local/freetype
- # ./configure --prefix=/usr/local/freetype
- # make
- # make install
d. 安裝 zlib
- # cd /root/Software/
- # tar -zxvf zlib-1.2.3.tar.gz
- # cd zlib.1.2.3
- # mkdir /usr/local/zlib
- # ./configure --prefix=/usr/local/zlib
- # make
- # make install
e. 安裝 GD 庫
- # cd /root/Software/
- # tar -zvxf gd-(version).tar.gz
- # mkdir -p /usr/local/gd2
- # cd gd-(version)
- # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
- # make
- # make install
e. 安裝 Curl 庫
- # cd /root/Software/
- # tar -zxf curl-(version).tar.gz
- # mkdir -p /usr/local/curl
- # ./configure --prefix=/usr/local/curl
- # make
- # make install
#p#
四:安裝 apache2
- # cd /roo/Software/
- # tar -zvxf httpd-2.2.6.tar.gz
- # cd httpd-2.2.6
- # mkdir -p /usr/local/apache2
- # ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
- # make
- # make install
- # /usr/local/apache2/bin/apachectl -k start // 啟動 apahce
用瀏覽器查看 http://localhost, 得到 it works ,說明 apache 已經(jīng)配置成功了 .
- # /usr/local/apache2/bin/apachectl -k stop // 停止 apache
#p#
五:安裝 php5
php5 必須有 libxml2 支持 !
a. 安裝 libxml2
- # cd /root/Software/
- # tar -zvxf libxml2-(version).tar.gz
- # cd libxml2-(version)
- # mkdir -p /usr/local/libxml2
- # ./configure --prefix=/usr/local/libxml2
- # make
- # make install
b. 安裝 libxslt ( 可選安裝,你可以不安裝 )
- # cd /root/Software/
- # tar -zvxf libxslt-(version).tar.gz
- # mkdir -p /usr/local/libxslt
- # cd libxslt-(version)
- # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
- # make
- # make install
c. 安裝 php5
- # cd /root/Software/
- # tar -zvxf php-(version).tar.gz
- # mkdir -p /usr/local/php5
- # cd php-(version)
- # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs \
- >--with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6 \
- >--with-zlib-dir=/usr/local/zlib \
- >--with-png-dir=/usr/local/libpng \
- >--with-freetype-dir=/usr/local/freetype -\
- >--enable-trace-vars --with-mysql=/usr/local/mysql \
- >--enable-mbstring=all --with-curl=/usr/local/curl --enable-mbregex \
- >--with-config-file-path=/usr/local/php5 --enable-ftp \
- >--enable-soap --with-xsl=/usr/local/libxslt
- # make
- # make install
- # cp php.ini-dist /usr/local/php5/php.ini
#p#
六:重新配置 apache2 讓他支持 php
- # cd /usr/local/apache2/conf
- # vim httpd.conf
- 在 LoadModule php5_module modules/libphp5.so
添加 AddType application/x-httpd-php .php
OK, 基本的安裝已經(jīng)完成 .
重新起動 APACHE:
- # /usr/local/apache2/bin/apachectl start
如果重新起動 APACHE 出現(xiàn) :
- Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server:
- /usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied
那就要按照下面的方法解決 :
1.chcon -t texrel_shlib_t /usr/local/apache2/modules/*.so
2. 編輯 /etc/selinux/config ,找到這段:
- # This file controls the state of SELinux on the system.
- # SELINUX= can take one of these three values:
- # enforcing - SELinux security policy is enforced.
- # permissive - SELinux prints warnings instead of enforcing.
- # disabled - SELinux is fully disabled.
- SELINUX=enforcing
把 SELINUX=enforcing 注釋掉: #SELINUX=enforcing ,然后新加一行為:
SELINUX=disabled
保存,關(guān)閉。
編輯 /etc/sysconfig/selinux ,找到 :
- # This file controls the state of SELinux on the system.
- # SELINUX= can take one of these three values:
- # enforcing - SELinux security policy is enforced.
- # permissive - SELinux prints warnings instead of enforcing.
- # disabled - SELinux is fully disabled.
- SELINUX=enforcing
如果 SELINUX 已經(jīng)是 SELINUX=disabled ,那么就不用改了,否則就把 SELINUX=enforcing 注釋掉,新加一行:
- SELINUX=disabled
保存,退出。
【編輯推薦】