您好,登錄后才能下訂單哦!
本篇文章為大家展示了Redhat Linux怎樣編譯安裝LAMP環境,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
一:準備軟件包
存放/home/xiutuo/software/目錄下。
主要軟件包:
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/lib
php5.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/lib php5.so into server:
/usr/local/apache2/modules/lib php4.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
保存,退出。
ok,web環境apache2+mysql5+ php5就介紹到這里。更詳細的apache2的配置和mysql配置和 php.ini的配置參考相應文檔
上述內容就是Redhat Linux怎樣編譯安裝LAMP環境,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。