mysql+apache+php的一些问题。

MYSQL:

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &

设置密码:

shell>bin/mysqladmin -u root password 'newpassword'

进入mysql:

shell>bin/mysql -uroot -p

Apache:

./configure --prefix=/opt/apache --enable-track-vars --enable-cgi --with-config-file-path=/opt/apache/conf

--prefix=/opt/apache 指定把apahce安装到/opt/apache目录中;
--enable-cgi 支持CGI;
--with-config-file-path=/opt/apache/conf 指定把apache的配制文件放在/opt/apache/conf中;比如httpd.conf配制文件就在这个目录中;

make
make install

/opt/apache/bin/apachectl start

vi /opt/apache/conf/httpd.conf

AddDefaultCharset ISO-8859-1
注:这句是指定网页的默认语言的,默认中文为"GB2312"。

DirectoryIndex index.html index.html.var
注:添加网站的默认页。

找到:
#AddType application/x-tar .tgz

加入:

AddType application/x-httpd-php .php

PHP:

1. gunzip apache_xxx.tar.gz
2. tar -xvf apache_xxx.tar
3. gunzip php-xxx.tar.gz
4. tar -xvf php-xxx.tar
5. cd apache_xxx
6. ./configure --prefix=/www --enable-module=so

(./configure --prefix=/usr/local/php --enable-fastcgi --enable-force-cgi-redirect --with-config-file-path=/etc/php --with-zlib --with-mysql=/opt/mysql --with-xml)

(./configure --prefix=/opt/php --with-mysql=/opt/mysql --with-apxs2=/opt/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/opt/php/etc)

--prefix=/opt/php 指定把php安装到/opt/php目录中;
--with-mysql=/opt/mysql 指定mysql数据服务器安装的位置;
--with-apxs2=/opt/apache/bin/apxs 这是加入apache中为DSO模块的位置;
-enable-track-vars 为启动cookie的get/post等追踪功能
--with-config-file-path=/opt/php/etc 指定php的配制文件存放的目录是/opt/php/etc目录,我们安装完成后,也要把php.ini复制到这个目录中来。

7. make
8. make install
9. cd ../php-xxx
10. cp php.ini-dist /usr/local/lib/php.ini
(cp php.ini-dist /etc/php/php.ini)
(cp php.ini-dist /opt/php/etc/php.ini)
vi /opt/php/etc/php.ini
找到:
default_charset = "iso-8859-1"
加一行
default_charset = "gb2312"

testphp
index.php
?>?>?>