今天特意配置了mysql apache php ,虽然网上很多这方面的例子,但是很多是作者再回忆写的,所以难免有笔误的地方。

而这些东西,正是新手很困惑的地方。一下是我的安装笔记,在Centos虚拟机上安装成功。

中文的参考:​​http://xieyu.blog.51cto.com/213338/59749​

英文的参考 ​​How to Install MySQL 5.0 on Linux​​,​​How to Install PHP 5 on Linux ​​,​​How to Install Apache 2 on Linux​


mysql apache php 安装过程。

将apache ,mysql ,php 的tar.gz 文件复制到/home/tmp目录。接着执行下面的命令

    mysql 安装
    1 cd /home/tmp

    2  groupadd mysql

    3  useradd -g mysql mysql

    4  tar -zxvf mysql-5.1.33.tar.gz

    5  cd mysql-5.1.33

    6  ./configure --prefix=/usr/local/mysql

    7  make

    8  make install

   14  cd /usr/local/mysql

   15  chown -R root .

   17  bin/mysql -u root -p

   18  chgrp -R mysql .(注意有个.)

   21  cd /home/tmp

   23  cd mysql-5.1.33

   25  ln -s /usr/local/mysql/ /usr/local/mysql

   26  cp support-files/my-small.cnf /etc/my.cnf 

    修改my.cnf 在[sqld]下面添加user=mysql.

   27  chown root /etc/my.cnf

   28  chgrp root /ect/my.cnf

   30  chmod 644 /etc/my.cnf

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

   36  cp support-files/mysql.server /etc/init.d/mysql

   37  chmod 755 /etc/init.d/mysql

   38  chkconfig --add mysql

   39  chkconfig --level 35 mysql on

   41  /usr/local/mysql/bin/mysql_install_db  --user=mysql

   42  /usr/local/mysql/bin/mysql -u root(如果能进入mysql 命令行,说明mysql 配置成功。)

edit /etc/my.cnf


[client]
+ default-character-set=utf8
[mysqld]
+ default-character-set=utf8
[mysql]
+ default-character-set=utf8


  apache安装,请先进入/home/tmp目录(cd /home/tmp)

   44  tar -zxvf httpd-2.2.13.tar.gz

   45  cd httpd-2.2.13

   46  ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-auth-digest=shared --enable-ssl --enable-deflate

   47  make

   48  history

   49  make install

   50  cp /usr/local/apache2/bin/apachectl  /etc/init.d

   51  chmod 755 /etc/init.d/apachectl 

   54  /usr/local/apache2/bin/apachectl start


    php的安装   56  cd /home/tmp

   58  tar -xzf php-5.3.0.tar.gz

   59  cd php-5.3.0

./configure --prefix=/usr/local/php \

--with-apxs2=/usr/local/apache2/bin/apxs \

--with-mysql=/usr/local/mysql \

--with-pdo-mysql \

--with-zlib \

--with-libxml-dir \

--with-xsl \

--enable-mbstring \

--enable-zend-multibyte \

--enable-sockets \

--enable-soap \

--enable-zip

   62  make

   65  make install

   修改apache httpd.conf(apache/conf/httpd.conf)

添加如下部分:

​LoadModule php5_module modules/libphp5.so ​​​​AddType application/x-httpd-php .php ​

   68  cp php.ini-development /usr/local/php/lib/php.ini

   69  /usr/local/apache2/bin/apachectl start

   70  /usr/local/apache2/bin/apachectl stop

   71  /usr/local/apache2/bin/apachectl start


附:mysql 允许远程连接

/usr/local/mysql/bin/mysql -u root -p  (进入mysql)

use mysql;

SELECT `Host`,`User` FROM user;

UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;

flush privileges;

注意在mysql 命令行形式下一定要输入";".


pdo_mysql

wget

http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

tar xzvf PDO_MYSQL-1.0.2.tgz

cd PDO_MYSQL-1.0.2

/usr/local/php/bin/phpize

Configuring for:

PHP Api Version: 20041225

Zend Module Api No: 20060613

Zend Extension Api No: 220060519

./configure --with-php-config=/usr/local/php/bin/php-config

经过configure就可以make了

make

make install注意pdo_mysql的全路径,我的是:

/usr/local/php/lib/php/extensions/debug-non-zts-20060613/pdo_mysql.so

然后在/usr/local/lib/php.ini

加上一句:

extension=/usr/local/php/lib/php/extensions/debug-non-zts-20060613/pdo_mysql.so

重新启动apache即可看到已经加载pdo_mysql成功。


mysql 的config例子


./configure --prefix=/usr/local/mysql-5.1.59 --enable-assembler --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg