您的位置:首页 > 运维架构 > Apache

linux mysql php apache 配置安装

2010-01-11 16:11 866 查看
 我们把下载的三个软件包放到/var/local目录下(这是笔者个人的习惯),它们都是tar.gz包,可以用命令tar -xzpvf 包名,把它们在当前目录(/var/local/)中解开:

cd /var/local
tar -xzpvf mysql-4.0.15.tar.gz
tar -xzpvf php-4.3.3.tar.gz
tar -xzpvf httpd-2.0.47.tar.gz
  解包后可以开始进入正式安装。

  安装MySQL

  1.编译

cd mysql-4.0.15/
../configure --prefix=/usr/local/mysql
make
make install
cd ..
  2.增加用户

adduser -s /bin/false mysql
  3.初始化并设置目录权限

/usr/local/mysql/bin/mysql_install_db
chown -R root /usr/local/mysql/
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/
  4.加入库

echo /usr/local/mysql/lib/mysql/lib >>/etc/ld.so.conf
ldconfig
  5.使之启动时自动运行

echo "/usr/local/mysql/bin/mysqld_safe &" >>/etc/rc.d/rc.local
  6.启动MySQL

/usr/local//mysql/bin/mysqld_safe &
  7.安全性设定

  修改MySQL的root密码:

/usr/local/mysql/bin/mysqladmin -uroot password abcdefg
  8.测试

[root@terry bin]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3 to server version: 4.0.15
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> delete from user where user=''; (删除所有用户名为空的用户,可以提高安全性)
Query OK, 2 rows affected (0.00 sec)
mysql> quit
Bye
  安装Apache

cd httpd-2.0.47/
../configure --prefix=/usr/local/httpd --enable-so
make
make install
cd ..
  现在已经将Apache 2.0.47安装到 /usr/local/httpd目录中,安装好的Apache支持可装载模块和标准的MPM prefork。如果安装过程中没有出现错误,便可以使用如下命令启动Apache服务:

/usr/local/httpd/bin/apachectl start
  如果启动成功,将启动命令加入rc.local,使之在系统启动时自动运行:

echo "/usr/local/httpd/bin/apachectl start &" >>/etc/rc.d/rc.local
  停止Apache服务,并继续安装PHP:

/usr/local/httpd/bin/apachectl stop
  安装PHP

  cd php-4.3.3

../configure --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql
make
make install
cp php.ini-dist /usr/local/lib/php.ini
  这种安装方式是将PHP作为Apache的SAPI模块来进行安装,它仅是其中的一种安装方式,更多的方法请参阅相关文档。

  PHP和Apache安装后的基本配置

  1.Apache的配置

  Apache的配置文件是/usr/local/httpd/conf/httpd.conf,编辑httpd.conf 文件,在文件结尾加上以下两行:

LoadModule php4_module modules/libphp4.so // php4_module 和libphp4.so 写的时候看你你下的版本而定
AddType application/x-httpd-php .php .php3
  同时修改DirectoryIndex为:

DirectoryIndex index.html index.php index.php3
  Apache的配置内容比较丰富,其它Apache相关配置请参考Apache的相关文档。

  2.PHP的配置

  Apache的配置文件是/usr/local/lib/php.ini,编辑php.ini文件来配置PHP的选项。特别注意的是,安装完成后register_globals变量默认设置为Off,需要将它改成On。否则会出现PHP读不到post的数据的现象。

register_globals=On
  其它PHP的选项请参考相关文档。

  3.测试

  可以写一个简单的PHP文件来测试安装,文件包含下列一行:

<? phpinfo();?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: