php + Mysql + apache 环境配置

安装顺序:apache -> mysql -> freetype -> jpegsrc.v6b -> libpng -> libxml -> zlib -> gd -> php  ( freetype,jpegsrc.v6b,libxml,zlib,libpng 的安装顺序不限)

 

  系统 CentOS 5.2

 

  所需软件版本 httpd-2.2.12.tar.gz ;

               mysql-5.1.43.tar.gz ; 

               libxml2-2.6.19.tar.gz ; 

               jpegsrc.v6b.tar.gz  ; 

               freetype-2.1.10.tar.gz  ;  

               zlib-1.2.3.tar.gz  ;

               libpng-1.2.8.tar.gz  ; 

               gd-2.0.33.tar.gz  ;

               php-5.2.3.tar.gz

 

 【1】 安装HTTP服务

       # tar zxvf httpd-2.2.12.tar.gz

       # cd httpd-2.2.12

 

       # ./configure --prefix=/usr/local/apache2 --enable-so --enable-vhost-alias

--enable-rewrite --enable-deflate --enable-mods-shared=all --with-mpm=worker

 

       # make&&make install

 

       //到这里如果没有出现错误,安装就算完成了,下面是启动命令: 

       # /usr/local/apache2/bin/apachectl start

 

       //然后查看是否有监听80端口

       # netstat -antlp | grep httpd

         tcp  0   0 :::80    :::*   LISTEN      8300/httpd

       //然后访问 http://102.168.0.146  有看到 It worker! 就证明服务有在运行了 

       //如果在启动的时候提示

       httpd: Could not reliably determine the server's fully qualified domain name, using ***.***.***.*** for ServerName

       //只要修改/etc/hosts里面的一些内容

       # vi /etc/hosts

       //原文其中一行:(IP根据自己的环境而定) 

       192.168.0.119   test localhost.localdomain localhost 

       修改为

       192.168.0.119   localhost.localdomain localhost  test

       就可以了 

       //设置系统启动时Httpd自启动

       # cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd 

       把

       # chkconfig: - 85 15

       # description: Apache is a World Wide Web server. It is used to serve /

       # HTML files and CGI.

       这些内容拷贝到/etc/init.d/httpd文件#!/bin/bash下面行。想让服务支持chkconfig工具必须在脚本里有chkconfig和description相关内容的描述。

       # chkconfig --add httpd           //添加httpd服务到系统

       # chkconfig httpd on              //打开httpd服务

       # service httpd start             //启动httpd服务

 

  【2】安装MYSQL

       # tar zxvf mysql-5.1.43.tar.gz

 

       # cd mysql-5.1.43

       # groupadd mysql    //创建MySQL组及的运行用户

       # adduser -g mysql mysql

       # ./configure /

--prefix=/usr/local/mysql /

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock /

--localstatedir=/usr/local/mysql/database/mysql_data /

--enable-assembler /

--with-mysqld-ldflags=-all-static /

--with-mysqld-user=mysql

<编译选项说明>:

--prefix=/usr/local/mysql:将所有文件安装到/opt/mysql 目录下

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock : 指定MySQL 的

Unix socket 文件存放的目录。

--localstatedir=/usr/local/mysql/database/mysql_data 指定mysql 的日志存放位置和数据库位置

--enable-assembler:允许使用汇编模式(优化性能)

--with-mysqld-ldflags=-all-static:服务器使用静态库(优化性能)

--with-mysqld-user=mysql:指定MySQL 的运行用户

        # make && make install

        #cp support-files/my-medium.cnf /etc/my.cnf   //拷贝Mysql配置文件到/etc下

        //初始化数据库:

        # cd /usr/local/mysql

        # mkdir –p /usr/local/mysql/database/mysql_data

        # bin/mysql_install_db --user=mysql //生成mysql.sock

        # chown -R root /usr/local/mysql          //将软件的安装目录拥有者改为root 用户

        # chown -R mysql /usr/local/mysql/database/mysql_data //将存放数据库的目录拥有者改为mysql

        # chgrp -R mysql /usr/local/mysql   // 将MySQL的安装目录属组改为mysql 组

        //启动数据库

        # /usr/local/mysql/bin/mysqld_safe --user=mysql &

        可查看是否监听了3306端口  netstat -antlp  

        //设置环境变量

        # export PATH=$PATH:/usr/local/mysql/bin

        //测试

        # mysql

          ...

        mysql>

        执行  show databases;

        +--------------------+

        | Database |

        +--------------------+

        | information_schema |

        | mysql |

        | test |

        +--------------------+

        3 rows in set (0.01 sec)

        看到以上结果证明数据库是正常的

        //设置MYSQL自启动

        a.  在 /etc/rc.local  最下面增加一行  /usr/local/mysql/bin/mysqld_safe --user=mysql&

        b.  增加在系统服务

            # cp /root/mysql-5.1.43/mysqlsupport-files/mysql.server /etc/init.d/mysql //mysql.server 在编译目录里面,具体路径根据自己环境而定。

            # chmod 755 /etc/init.d/mysql  //修改权限

            # chkconfig --add mysql       //增加此服务  可以通过chkconfig --list查看

            # service mysql start        //启动数据库 

        // 给mysql的root用户设置密码

         #mysqladmin -u root password 'admin'

 

    【3】安装库文件

        (1) libxml     //libxml2-2.6.19.tar.gz      

          # tar zxvf libxml2-2.6.19.tar.gz

          # cd libxml2-2.6.19

          # ./configure --prefix=/usr/local/libxml2

          # make

          # make install

        (2) jpeg6      //jpegsrc.v6b.tar.gz

          # tar zxvf jpegsrc.v6b.tar.gz

          # mkdir /usr/local/jpeg6 

          # mkdir /usr/local/jpeg6/bin 

          # mkdir /usr/local/jpeg6/lib 

          # mkdir /usr/local/jpeg6/include 

          # mkdir /usr/local/jpeg6/man 

          # mkdir /usr/local/jpeg6/man/man1

          # cd jpeg-6b

          # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static

          # make

          # make install

        (3)freetype    //freetype-2.1.10.tar.gz

          # tar zvxf freetype-2.1.10.tar.gz 

          # cd freetype-2.1.10

          # ./configure --prefix=/usr/local/freetype 

          # make

          # make install

        (4) zlib       //zlib-1.2.3.tar.gz

          # tar zvxf zlib-1.2.3.tar.gz 

          # cd zlib-1.2.3

          # ./configure --prefix=/usr/local/zlib

          # make

          # make install

        (5) libpng     // libpng-1.2.8.tar.gz

          # tar zxvf libpng-1.2.8.tar.gz

          # cd libpng-1.2.8

          # cp scripts/makefile.std makefile

          # make 

          # make install

        (6) gd        //gd-2.0.33.tar.gz

          # tar zxvf gd-2.0.33.tar.gz

          # cd  gd-2.0.33

          # ./configure --prefix=/usr/local/gd2 --with-png=/usr/local/lib --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6 --with-libxml=/usr/local/libxml2/

          # make

          # make install

 

      【4】安装PHP    //php-5.2.3.tar.gz 

          # tar zxvf php-5.2.3.tar.gz

          # cd  php-5.2.3

          # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/zlib --with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --enable-xml --enable-mbstring --enable-sockets

          # make

          # make test    //这边是测试会不会出错,可省略

          # make install

          # cp php.ini-dist /etc/php.ini

 

       【5】整合apache+php

          //修改http.conf配置文件,对PHP的支持

          # vi /usr/local/apache2/conf/httpd.conf

          在AddType application/x-gzip .gz .tgz下边添加

          AddType application/x-httpd-php .php

          AddType application/x-httpd-php-source .phps

          //注意.php前有一个空格

          把DirectoryIndex index.html改成

          DirectoryIndex index.html index.php

          //修改虚拟目录

          #vi /etc/php.ini

          把register_globals = Off  改成register_globals = On

          然后在/usr/local/apache2/htdocs/下写个测试页面index.php,内容如写

          <?phpinfo()?> 

          然后访问http://192.168.0.119/index.php

          如果有看到php页面,就证明OK了

 

       【6】安装 phpmyadmin

          # tar zxvf phpMyAdmin-2.7.0-pl2.tar.gz

          # cp -a phpMyAdmin-2.7.0-pl2 /usr/local/apache2/htdocs/phpmyadmin

          # cd /usr/local/apache2/htdocs/phpmyadmin

          # cp config.default.php config.inc.php     // 配置文件config.inc.php

          //修改配置文件config.inc.php 

          # vi config.inc.php

          找到 $cfg['PmaAbsoluteUri'] 修改成站点地址 

           如:$cfg['PmaAbsoluteUri'] = 'http://192.168.0.119/phpmyadmin/';

          找到 $cfg['Servers'][$i]['host'] = 'localhost'; // 通常用默认,也有例外,可以不用修改 

          找到 $cfg['Servers'][$i]['auth_type'] = 'config'; // 在自己的机子里调试用config;如果在网络上的空间用cookie,这里我们既然在前面已经添加了网址,就修改成cookie ,这里建议使用cookie  

          找到 $cfg['Servers'][$i]['user'] = 'root'; // MySQL user用户名,自己机里用root;

          找到 $cfg['Servers'][$i]['password'] = ''; // MySQL password 

          找到 $cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only(你只有一个数据就设置一下;如果你在本机或想架设服务器,那么建议留空)

          找到 $cfg['DefaultLang'] = 'zh'; (这里是选择语言,zh代表简体中文的意思) 

          然后访问 http://192.168.0.119/phpmyadmin 即可

      <我在访问的时候出现“配置文件现在需要绝密的短语密码(blowfish_secret)。”这样的错误   百度一下 

          编辑config.inc.php

          找到: $cfg['blowfish_secret'] = '';

          这里设上你的域名或随便填几个字> 

       就搞定了,搜索引擎真好..... 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值