歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> LAMP安裝配置

LAMP安裝配置

日期:2017/3/1 17:21:21   编辑:關於Linux
主要軟件包,
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/目錄下.
二:安裝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目錄權限
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/data
生成mysql系統數據庫
# /usr/local/mysql/scripts/mysql_install_db --user=mysql& //啟動mysql服務
# /usr/local/mysql/bin/mysqld_safe --user=mysql&
如出現Starting mysqld daemon with databases from /usr/local/mysql/data 代表正常啟動mysql服務了.
按Ctrl + C 跳出修改mysql 的root 密碼
# /usr/local/mysql/bin/mysqladmin -u root -p password "123456"
三:安裝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
四:安裝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已經配置成功了.
# /usr/local/apache2/bin/apachectl -k stop //停止apache
五:安裝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 (別忘記了呵呵)
六:重新配置apache2讓他支持php
# cd /usr/local/apache2/conf
# vim httpd.conf
在LoadModule php5_module modules/libphp5.so
添加AddType application/x-httpd-php .php
OK,基本的安裝已經完成.
重新起動APACHE:
# /usr/local/apache2/bin/apachectl start
如果重新起動APACHE出現:
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
保存,關閉。
編輯/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已經是SELINUX=disabled,那麼就不用改了,否則就把SELINUX=enforcing 注釋掉,新加一行:
SELINUX=disabled
保存,退出。


摘自 PainsOnline的專欄
Copyright © Linux教程網 All Rights Reserved