`

Red Hat Linux下MySql+Apache+PHP配置

 
阅读更多

详细介绍:Apache+PHP+MySQL配置攻略

 

所需安装源文件
apache-2.0.63
freetype-2.1.10
gd-2.0.28
jpeg-7
libmcrypt-2.5.7
libpng-1.2.5
libxml2-2.6.11
mcrypt-2.6.4
mhash-0.9.9.9
mysql-5.0.81
php-5.3.3
zlib-1.2.3


1. 安装mysql
  安装步骤: 

cd mysql-5.0.81
./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql/
make
make install  

 
  根据机子的性能,编译过程要花费一定的时间,编译完成后系统默认把mysql安装在/usr/local下。
  安装完成后,先把mysql的进程启起来 
  cd /usr/local/bin 
  ./mysql_install_db(安装mysql的基本数据库) 
  ./safe_mysqld & (把进程启起来并转入后台) 
  到这里mysql算安装完成了,试试运行./mysql看看能不能链接数据库,如果正常的话,应该可以看到这样的界面     
Welcome to the MySQL monitor.Commands end with ; or g. 
Your MySQL connection id is 880 to server version: 3.22.40 
Type 'help' for help. 
mysql> 
  到这恭喜你完成了mysql的安装 

#启动mysql server 
/usr/mysql/safe_mysqld &
mysql #运行mysql 客户端,并开放root用户的远程访问权限。以便调试 
use mysql 
update user set host = '%' where user = 'root' and host <> 'localhost'; 
flush privileges; 
quit 


2. 安装apache 

  在如下页面下载apache的for linux 的源码包 
  http://www.apache.org/dist/httpd/; 
  存至/home/tmp目录 
  命令列表: 

./configure --prefix=/usr/local/apache \
--enable-dav  \
--enable-module=rewrite \
--enable-so  \
--enable-maintainer-mode  \
--enable-mods-shared=all  \
--enable-ssl=shared  \
--with-ssl ;

make 
make install   

 
安装apache至/usr/local/apache 并配置apache支持dso方式 
 /usr/local/apache/bin/apachectl -M  -t -D DUMP_MODULES 安装了哪些模块
/usr/local/apache/bin/apachectl -t    测试安装是否成功
/usr/local/apache/bin/apachectl -k start|restart|stop 查看详细


五 .  安装整合 PHP  apache、php

安装支持库


 编译和安装libxml2 XML解析器,这一解析器提供PHP 5.0新的XML APL:
  

tar zxvf libxml2-2.6.32.tar.gz
cd libxml2-2.6.32
./configure --prefix=/usr/local/libxml
make
make install
   
  这一步结束时,libxml2被安装在/usr/local/下。如果你想把它安装在其它地方,你应该在先前步骤中明确指定prefix选项到configure设置中。 
  

 

 

安装加密模块mcrypt

 

 

源码编译安装,去http://www.sourceforge.net下载Libmcrypt,mhash,mcrypt安装包 
libmcrypt(libmcrypt-2.5.8.tar.gz ):
mcrypt(mcrypt-2.6.8.tar.gz ):
  mhash(mhash-0.9.9.9.tar.gz ):


a .先安装Libmcrypt

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install 


b.安装mhash

tar -zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install

c.安装mcrypt

tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
LD_LIBRARY_PATH=/usr/local/lib ./configure
make
make install

 

 

 

安装gd   需要一些依赖库,安装步骤如下:

1、 安装 zlib

mkdir /usr/local/zlib
cd zlib-1.2.5
./configure
make
make install
  2、安装 libpng  下载地址 http://www.libpng.org/pub/png/libpng.html

 

#tar -xzf libpng-1.2.23.tar.gz    
#cd libpng-1.2.23                 
#cp scripts/makefile.linux makefile
#make       
#make install
   3、 安装 freetype
mkdir /usr/local/freetype
tar -xf freetype-2.3.12.tar.gz
cd freetype-2.3.12
./configure --prefix=/usr/local/freetype
make
make install
     4、 安装 jpeg  下载地址 http://www.ijg.org/ 
cd jpeg-6b
./configure --enable-shared --enable-static
make
make install
   5、 安装 gd
tar -zxf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --with-jpeg --with-png --with-freetype
make
make install
  

php 安装

 

./configure --prefix=/usr/local/php --enable-soap --enable-sockets --enable-mbstring \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-curl \
--with-libxml-dir=/usr/local/libxml \
--with-mcrypt \
--with-zlib \
--with-gd \
--with-zlib-dir=/usr/local/lib \
--with-png-dir=/usr/local/lib \
--with-jpeg-dir=/usr/local/lib \
--with-freetype-dir=/usr/local/lib \
;
make 
make install 

   
  以上例子看起来相当复杂,然而事实并非如此:  
  --prefix设置PHP5 的安装路径。  
  --with-apxs2告诉PHP查找Apache 2.0的地方。  
  --with-libxml-dir和 --with-zlib-dir告诉PHP放置libxml2和zlib库的地方。  
  --with-mysql变量激活regularmySQL扩展功能。  
  --with-mysqli变量激活新增加的MySQL功能。  
  --with-gd变量激活 GD 扩展功能。  
  --with-zlib变量激活ZLIB 压缩库。  
  --enable-sockets变量激活socket通讯特性。  
  --enable-soap变量激活SOAP和Web services支持。  
  当然,也可以尝试其它选项和扩展功能:  
  可以注意到,这些安装过程能够自动将PHP模块安装在正确目录下,以便Apache 2.0的查找。


在 httpd.conf 配置文件中修改如下:

 

加载php模块
LoadModule php5_module modules/libphp5.so


#将ServerAdmin mailto:linux@linuxidc.com一行改为您的邮箱地址  
#DocumentRoot "/home/httpd/html/" 此处为html文件主目录   
# 同上   
#Options FollowSymLinks MultiViews 为安全起见,去掉"Indexes"    

# DirectoryIndex default.php default.phtml default.php3 default.html default.htm 

#设置apache的默认文件名次序   
AddType application/x-httpd-php .php .phtml .php3 .inc 
AddType application/x-httpd-php-source .phps
#设置php文件后缀   
另外还要修改系统默认的首页类型,建议把DirectoryIndex index.htm改成这样: 
DirectoryIndex index.htm index.html index.php3 index.php default.php  

#ServerName [url]www.example.com:80[/url]
ServerName 127.0.0.1
 
修改网站主目录如下
#DocumentRoot "/usr/local/apache/htdocs"
DocumentRoot "/var/www/html"
 
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
# 首先配置的缺省的限制,这个限制是非常严格的
<Directory />
    Options FollowSymLinks
    AllowOverride None
  Order deny,allow  次序是先拒绝,再允许
    Deny from all  默认是拒绝所有
</Directory>
 
# This should be changed to whatever you set DocumentRoot to.
#这里应该改为你设的DocumentRoot
<Directory "/usr/local/apache22/htdocs">  修改为网站主目录
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # [url]http://httpd.apache.org/docs/2.2/mod/core.html#options[/url]
    # for more information.
    #
    Options Indexes FollowSymLinks
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None
 
    #
    # Controls who can get stuff from this server.
    #控制谁能访问这个网站
    Order allow,deny  顺序是先允许再拒绝
    Allow from all  默认是允许所有
 
</Directory>
 
 





5.测试   
然后写个php测试页info.php:内容如下
〈?php
phpinfo(); 
?> 
正常的话,应该能看到php的信息了,恭喜你的Apche+Mysql+PHP安装成功。 
6、apache自动启动- - 
下面用自启动apache为例;
自启动脚本:
/usr/local/apache/bin/apachectl start
文件位于/etc/rc.d/init.d下,名为apached,注意要可执行.
#chmod +x /etc/rc.d/init.d/apached //设置文件的属性为可执行
#ln -s /etc/rc.d/init.d/apached /etc/rc3.d/S90apache //建立软连接,快捷方式 
#ln -s /etc/rc.d/init.d/apached /etc/rc0.d/K20apache




  6.备注 
   apache在linux下的默认最大进程数为256,无论如何修改httpd.conf都不能超过这个限制。如果想加大这个限制,在编译apache 前编辑/home/tmp/apache/src/include/httpd.h,将其中#define HARD_SERVER_LIMIT 256 一行改为#define HARD_SERVER_LIMIT 2048后再编译apache, 

  apache 1.3.26中mod_so似乎已经不是默认模块了。编译时候需加上--enable-module=so,我第一次编译没加此参数,结果php编译时无法找到apxs 

  php 4.2.3中默认配置文件路径似乎变了。编译时需加上 --with-config-file-path=/usr/local/lib 参数,我第一次编译完php.ini放了n个地方都没有用。不得已。只能加上这个参数。 



分享到:
评论

相关推荐

    Red Hat Enterprise Linux 5 安装配置 Apache + MySQL

    Red Hat Enterprise Linux 5 安装配置 Apache + MySQL

    red hat 9linux最佳LAMP配置

    本人亲自安装的经过。一边安装一边记录,参考的是php兄弟连的相关书籍,在linux下配置最佳apache+mysql+php环境!如果安装中途有什么疑问可以留言探讨……

    Red_Hat_Enterprise_Linux服务器配置

    详细介绍了RHEL的安装,DNS、APACHE、FTP、Mysql、samba、NFS和mail服务器的详细配置

    linux服务器安装及其他安装一(打包)

    Apache服务器配置技巧,Linux+Apache+MySQL+PHP,linux 系统管理篇--环境变量,Linux操作系统网卡安装指南,linux系统安装总结,linux下几种服务器的配置使用之二,安装Red Hat 9.0,Linux系统新手学习的11点建议...

    Linux和Solaris建立Apache虚拟根环境

    本文对apache在linux和soloris环境下实现虚拟根环境的安装进行说明。在Linux上安装一个虚拟根环境化的Apache目录树是相当的简单的。这个例 子使用的是Red Hat 6.*和Apache 1.3.12。同时,它也包含PHP4(作为一个...

    Linux下 php5 MySQL5 Apache2 phpMyAdmin ZendOptimizer安装与配置[图文]

    本例是在red hat 9下 php5.2.1 apache2.2.4 MySQL5.0.37 phpmyadmin2.10.0.2 ZendOptimizer-3.2.6 libxml2-2.6.11 的安装与配置 其中 libxml2-2.6.11 我下载在 /usr/ 目录下 其他都下载在 /usr/down 目录下....

    Linux搭建Discuz论坛 (功成版) (dos)

    red hat linux5环境下配置的,安装linux系统前请不要安装mysql,apache,服务, 里面提到的软件可以到官方下载最新版本的,经测试安装成功……

    CentOS VPS安装Kloxo免费虚拟主机管理系统

    Kloxo简介 Kloxo的前身是lxadmin,是一款免费的虚拟主机管理系统,安装简单,功能强大,可以快速地在red hat,centos系列linux系统的主机上搭建LAMP(Linux+Apache+Mysql+Perl/PHP/Python)环境。 安装kloxo Kloxo...

    Linux环境数据库管理员指南

    第2章 Red Hat Linux基本安装 16 2.1 引言 16 2.1.1 物理上独立的机器 16 2.1.2 选择 Linux分发包 16 2.2 初步的安装决定 17 2.2.1 硬件 17 2.2.2 多CPU 17 2.2.3 RAM 17 2.2.4 磁盘 17 2.2.5 RAID 18 2.2.6 网络...

    畅通无阻-高效架设RedHatLinux服务器

    本教材从零开始,由浅入深,全面采用X Window和Webmin相结合的图形管理界面作为配置手段,开创了Linux管理的新概念,让您无需记忆Linux的命令,就能轻松快速地完成Red Hat Linux 9各种流行网络服务器的配置与管理。...

    MySQL 5权威指南(第3版) 中文版 下载地址

     2.4 在Red Hat Enterprise Linux 4系统上安装MySQL和相关软件  2.5 编译MySQL软件的开发者版本(Linux)  2.6 配置Apache  2.7 配置PHP  2.8 配置MySQL  第3章 初级案例研究:MySQL+PHP  3.1 概述  ...

    Linux下ZendOptimizer的安装与配置方法

    内容: 在装的好的Red Hat Linux 9 + Apache 2.0.55 + MySQL 5.1.6 + PHP 5.1.2后,接下来就是安装linux下的php加速器ZendOptimizer 2.6.2了。 自己编译 PHP 后,Zend Optimizer 2.6.2 需要自己...

    redhat 5.4下安装MYSQL全过程

    购买的机器配置是: 操作系统:Red Hat Enterprise Linux Server 5.4 64位。 CPU:1核 内存:512M 硬盘空间:20G 带宽:1Mbps。 安装MYSQL数据需要用到以下三个包: MySQL-server-5.5.32-1.rhel5.x86_64.rpm MySQL-...

    MySQL5 权威指南第3版中文版_part1

     2.4 在Red Hat Enterprise Linux 4系统上安装MySQL和相关软件  2.5 编译MySQL软件的开发者版本(Linux)  2.6 配置Apache  2.7 配置PHP  2.8 配置MySQL  第3章 初级案例研究:MySQL+PHP  3.1 概述  3.2 ...

    LAMP安装以及配置详解

    安装LAMP分为两种稍有不同的方法,方法的不同主要是因为所使用的PHP的版本不同... 1 PHP 4.4.4 安装环境:Red Hat Linux 注意事项:安装LINUX的时候,不要安装系统自带的apache(在Linux下名为httpd),也不要安装mysql

    《Linux宝典 2010版》(Wiley Linux Bible 2010 Edition)(Christopher Negus)文字版

    Chapter 13: R unning a Linux, Apache, MySQL, and PHP (LAMP) Server. Chapter 14: Running a Mail Server. Chapter 15: Running a Print Server. Chapter 16: Running a File Server. Part V: Choosing and ...

    PHP程序开发范例宝典III

    实例005 使用AppServ架设Apache+MySQL+PHP运行环境 8 实例006 使用IIS服务器运行PHP脚本 10 实例007 Windows下发布“明日科技”网站 12 1.2 Linux下环境配置 14 实例008 Linux下Apache1.x安装配置 14 实例...

    爱站CMS内容管理系统 v2.1

    安装要求:爱站CMS安装系统及软件要求:操作系统:Windows、Linux、Unix等各种平台,推荐Red Hat Enterprise Linux6.2以上应用服务器:Apache, 推荐Apache/2.2.22以上数据库:MySQL5.1+ 推荐MySQL5.5爱站CMS V2.1...

Global site tag (gtag.js) - Google Analytics