Home > Article > Backend Development > linux下装php5+mysql5+apache 2的笔记
环境是red hat linux 4+MySQL5+apache 2+php5
1、安装apache:
tar zvxf httpd-2.0.46.tar.gz
cd httpd-2.0.46
./configure –PRefix=/usr/local/apache2 –enable-so \
–enable-mods-shared=most &&
make &&
make install
设定开机自动启动apache
方法一:在/etc/rc.d/rc.local中加入 /usr/local/apache/apachectl start
方法二:见chkconfig 添加httpd的方法
2、安装mysql5:
首先当然是解压缩了 tar xzvf xxx.gz
./configure –prefix=/usr/local/mysql
make && make install
改相关权限,
cp support-files/my-medium.cnf /etc/my.cnf
建立MySQL使用者和群组:
CODE:
#groupadd mysql
#useradd -g mysql mysql
完成以上操作以后进行初始化数据库,进入已经安装好的mysql目录
CODE:
#cd /usr/local/mysql
#bin/mysql_install_db –user=mysql |注:–user=mysql 初始化表并且规定用mysql用户
设置给mysql和root用户设定访问权限 我们先进入mysql目录
CODE:
#cd /usr/local/mysql
#chown -R root /usr/local/mysql |注:设定root能访问/usr/local/mysq
#chown -R mysql /usr/local/mysql/var |注:设定mysql用户能访问/usr/local/mysql/var
#chgrp -R mysql /usr/local/mysql |注:设定mysql组能够访问/usr/local/mysq
启动mysql,进入已经安装好的目录
CODE:
#cd /usr/local/mysql
#bin/mysqld_safe –user=mysql &
修改mysql数据库超级用户root的缺省密码:
/usr/local/mysql/bin/mysqladmin -u root passWord ‘新密码’
关闭mysql服务器
cd /usr/local/mysql/bin
./mysqladmin -u root -p shutdown
设定开机就启动mysql,进入源码目录下
# cd /home/seal/mysql
# cp support-files/mysql.server /etc/init.d/mysql
http://www.cncms.com/
# chmod +x /etc/init.d/mysql
# chkconfig –level 345 mysql on
(说明:linux启动的5个等级,1,2,3,4,5 在3,4,5这三个中均要求llinux启动MySQL这个服务。有些类似windows的不同模式,比如安全模式)
# service mysql restart
Shutting down MySQL. [ 确定 ]
Starting MySQL [ 确定 ]
3 安装php
tar zvxf php5.tar.gz
./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql \
–with-apxs2=/usr/local/apache/bin/apxs &&
make &&
make install
cp php.ini-dist /usr/local/php5/etc/php.ini
vi /usr/local/php5/etc/php.ini
将extension=php_mysql.dll前面的#去掉
当然可以也将其他的一些东西也去掉
4 修改httpd.conf
增加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
另外要显示中文的话,
修改:
AddDefaultCharset gb2312
设置虚拟目录
Alias /myphp “/home/myphp/”
AllowOverride None
Order deny,allow
http://www.086php.com/index.php/rcd-2/566