系统环境:Linux rhel5.1 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />2.6.18-53.el5
apache的安装
下载httpd-2.2.13.tar.gz
tar zxvf httpd-2.2.13.tar.gz //解压
cd httpd-2.2.13 //进到解压的目录
./configure –prefix=/usr/loca/apache2 –enable-so --enable–rewrite //生成makefile 文件,各选项含义如下:
--prefix 指定apache的安装路径
–enable-so 使用动态加载模块功能
--enable–rewrite 设置 apache服务器具有 rewrite功能
make
make install
vi /usr/local/apache2/conf/httpd.conf //修改配置文件
找到DocumentRoot “/usr/local/apache/htddocs”
修改为:DocumentRoot “/var/www” //指定WEB的目录
找到<Directory “/usr/local/apache/htdocs”>
修改为:<Directory “/var/www”> //修改WEB服务器文档的根 目录
找到
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all //这句改为Allow from all<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
修改为:<Directory “/var/www”> //修改WEB服务器文档的根 目录
找到
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all //这句改为Allow from all<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
ServerName 192.168.0.10:80 //指定IP或者域名
mkdir /var/www //建立WEB根目录
/usr/local/apache2/bin/apachectl start //启动apache服务
vi /etc/rc.local //修改启动脚本,使apache服务开机启动,在最后加上以下内容:
/usr/local/apache2/bin/apachectl start
cp /usr/local/apache2/htdocs/index.html /var/www/ //把这个主页文件CP到WEB根目录,以便测试;
测试apache是否正常启动
ps aux | grep httpd查看httpd进程是否存在,
ps aux | grep httpd查看httpd进程是否存在,
netstat --an | grep 80查看
也可以通过浏览器输入服务器的IP,如果有测试页“It works!”出现,刚证明已经安装成功。
Mysql的安装
下载:mysql-5.0.67-linux-i686.tar.gz
tar zxvf mysql-5.0.67-linux-i686.tar.gz -C /usr/local/mysql //解压
cd /usr/local/mysql //进入解压目录
groupadd mysql //添加组
useradd –g mysql –s /sbi n/nologin –M mysql //添加用户
./configure –prefix=/usr/local/mysql
cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件到/etc目录下
chown –R mysql,mysql /usr/local/mysql //改变目录的宿主及属组
/usr/local/mysql/scripts/mysql_install_db //初始化数据库
chgrp -R root /usr/local/mysql/
/usr/local/mysql/bin/mysqld_safe --user=mysql & //启动数据库服务,并以mysql用户运行
cp support-files/mysql.server /etc/rc.d/init.d/mysqld //添加到服务启动脚本目录
chmod 755 /etc/rc.d/init.d/mysqld //权限
chkconfig –add mysqld //添加到chkconfig管理
chkconfig –level 35 mysqld on //设置在35动行级别开机启动
/usr/local/mysql/bin/mysqladmin –u root password “123456” //更改root用户的数据库密码
/usr/local/mysql/bin/mysql –u root –p //以root用户登录数据库
输入密码:123456,看能不能进入数据库
PHP的安装
下载php-5.2.10.tar.gz
tar xzvf php-5.2.10.tar.gz //解压
cd php-5.2.10 //进入解压目录
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-
mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-
file-path=/usr/local/php --with-zlib --enable-mbstring=all //生成makefile文件,各选项含义如下:
mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-
file-path=/usr/local/php --with-zlib --enable-mbstring=all //生成makefile文件,各选项含义如下:
--prefix=/usr/local/php //指定PHP安装目录
--with-apxs2=/usr/local/www/bin/apxs //设置PHP为Apache服务器提供的模块安装位置
--with-mysql=/usr/local/mysql/ //指定mysql的位置
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-config-file-path=/usr/local/php //设置PHP配置文件存放位置
当看到以下信息时:
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
make
make install
cp php.ini-dist /usr/local/php/php.ini //把配置文件CP到/usr/local/php/下
vi /usr/local/apache2/conf/httpd.conf //修改配置文件
添加一句
AddType application/x-httpd-php .php .phtml //让apache服务器识别PHP类型的文件
找到DirectoryIndex index.html
在后面添加index.php //让apache服务器能正确处理.php类型的index文件
vi /usr/local/apache2/conf/httpd.conf //修改配置文件
添加一句
AddType application/x-httpd-php .php .phtml //让apache服务器识别PHP类型的文件
找到DirectoryIndex index.html
在后面添加index.php //让apache服务器能正确处理.php类型的index文件
重新启动apache
vi /var/www/test.php
<?
tphpinfo();
?>
浏览器输入IP/test.php,测试一下是否显示PHP的测试页,要是显示出来就表示已经安装成功了。
转载于:https://blog.51cto.com/kyhack/200300