linux下的Apache2 + mysql5 + php5 安装详解 zt (2008-03-04 12:12)
分类: linux
linux下的Apache2 + mysql5 + php5 源码完整安装详解
原来出处找不到了,恰巧是您的大作请海涵:-)
一:准备软件包,存放/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
这上安装不成功用这个
/lib/cpp fails sanity check的解决
在某些软件的时候,运行./configure 会报错,错误提示为:
configure: error: C++ preprocessor “/lib/cpp” fails sanity
check See `config.log’ for more details
解决办法:出现该情况是由于c++编译器的相关package没有安装,以root用户登陆,在终端上执行:
# yum install glibc-headers
# yum install gcc-c++
还是不成功(php)用下面这个
yum install libxml2-devel
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
保存,退出。
ok,web环境apache2+mysql5+php5就介绍到这里。更详细的apache2的配置和mysql配置和php.ini的配置参考相应文档
分享到:
相关推荐
php环境搭建。apache安装,mysql安装,整合安装的过程,安装步骤。
Centos7版本搭建Linux-Apache-PHP-Mysql环境
本文档想洗介绍了在linux操作系统下 Centos7 搭建 PHP7.2 + Apache 2.4 + mariadb 10.2
Linux环境是在VMware虚拟机中搭建的,重在学习,安装的系统是CentOS6.5-64bit。本文主要讲诉在CentOS中如何安装APACHE。
linux下apahce mysql php环境的搭建,centos 防火墙的开启与关闭, centos6下php版本的升级
这是一篇以图文形式讲解在centos5.5下面搭建以oracle为数据库的服务器以及apache和php在linux下安装时的相关细节设置
CentOS下快速搭建LAMP环境,Linux + Apache + MySQL + PHP。
本篇文章介绍了centos下yum搭建安装linux+apache+mysql+php环境,对学习centos有一定的参考价值,感兴趣的小伙伴们可以参考一下。
准备在阿里云的ESC Centos7.3环境下搭建Lamp环境(Linux+Apache+Mysql+Php),在此顺便记录一下,注意以上搭建的环境一般centos7版本以上的都可以! 首先进行一些准备工作: 1、CentOS 7.3 系统默认开启防火墙 ...
环境搭建过程中,编译安装PHP最艰辛。需要安装的依赖组件太多。现在整理记录一下。也希望对读者能有所帮助
CentOS 7 搭建 LAMP 环境与配置介绍LAMP 架构介绍安装与配置安装 Apache安装阶段配置阶段安装 MySQL安装阶段安装 PHP安装阶段MySQL 导入数据库文件导入数据库方法一:MySQL 命令方法二:source 命令 介绍 该博文将...
研究了两天Linux下安装Oracle,重装了两次虚拟机,终于安装成功。很有收获的。记录下安装过程。大神们如有更好的方式,请联系我!
LMAP_Linux,Apache,Mysql,PHP环境搭建教程,很详细
主要介绍了centos下yum搭建安装linux+apache+mysql+php环境的方法,本文分步骤给大家介绍的非常详细,具有参考借鉴价值,需要的朋友可以参考下
完整的linux(RedHat5.4)+php5.3.10+mysql5.5.19+apache2.2.22安装配置说明,redhat和centos系统通用,让你轻松的完成php在linux环境下搭建一个完美的LAMP平台。完整的LAMP环境安装手册,php学习者必备的文档说明。
【吐血推荐】nginx+apache+mysql+php+memcached+squid搭建集群web环境(二) 此乃本人N次服务器真机实验所得,所以分数高点,望体谅.. 按教程来做,你也可以搭建linux服务器... 注:此乃分卷二,
php+mysql+apache 所需的资源及教程 包括: mysql-5.0.67-linux-i686-icc-glibc23.tar.gz httpd-2.2.11.tar.gz jpegsrc.v6b.tar.gz zlib-1.2.3.tar.gz libpng-1.2.34.tar.gz freetype-2.1.10.tar.gz gd-2.0.33.tar....
很全面的一个在centos下搭建lamp(linux+mysql+apache+php)的架构的文档,有图有真相哦,有兴趣可以下载