Linux环境下网站平台的搭建 MySQL+apache+PHP

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:611

[size=14px]2.解压缩所需文件
[size=14px] tar -zxvf 压缩包全名 (使用于以.tar.gz压缩的包解压缩)
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093244598.gif[/img]
[size=14px] 3.进入源码目录
[size=14px] cd mysql-版本
[size=14px] 4.创建MySQL组
[size=14px] groupadd mysql
[size=14px] 5.建立mysql用户并指定到MySQL组中
[size=14px] useradd -g mysql mysql
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093244599.gif[/img]
[size=14px] 6.编译前准备
[size=14px] ./configure --prefix=/usr/local/mysql
[size=14px] 如果出现下面的错误,则不要着急,只需Google一下就可以了,一般类似的问题都可以找到的。
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093244600.gif[/img]
[size=14px]只要输入下面的命令:
[size=14px] echo '/* Linuxthreads */' >> /usr/include/pthread.h
[size=14px]然后再来准备一下,重复./configure --prefix=/usr/local/mysql此命令即可。
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093244601.gif[/img]
[size=14px] 7.编译
[size=14px] make
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093245602.gif[/img]
[size=14px] 8.编译安装
[size=14px] make install
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093245603.gif[/img]
[size=14px] 9.复制MySQL的配置文件
[size=14px] cp support-files/my-medium.cnf /etc/my.cnf
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093245604.gif[/img]
[size=14px] 10.进入安装目录
[size=14px] cd /usr/local/mysql/
[size=14px] 11.使用MySQL用户初始化数据库
[size=14px] bin/mysql_install_db --user=mysql
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093245605.gif[/img]
[size=14px] 12.将当前目录下所有文件属主改为超级用户
[size=14px] chown -R root .
[size=14px] 13.var目录中所有文件属主改为MySQL
[size=14px] chown -R mysql var
[size=14px] 14.当前目录下所有文件属组改为MySQL
[size=14px] chgrp -R mysql .
[size=14px] 15.后台运行MySQL数据库
[size=14px] bin/mysqld_safe --user=mysql &
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093245606.gif[/img]
[size=14px] 16.检验,可以通过查看端口的方法检验一下服务是否起来了
[size=14px] netstat -an | grep 3306
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093246607.gif[/img]

[size=14px]二、apache的安装
[size=14px] 1.下载文件(前面过程和MySQL的雷同)
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093246608.gif[/img]
[size=14px] 2.解压缩文件
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093246609.gif[/img]
[size=14px] 3.进入源码目录
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093246610.gif[/img]
[size=14px] 4.编译前准备
[size=14px] 这里先来检查一下防火墙是否关闭,若没关闭先关掉防火墙,否则会报错: 用setup来查看相关的配置
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093257611.gif[/img]
[size=14px]这里防火墙已经关闭了,确定关闭后再输入下面的命令
[size=14px] ./configure --prefix=/usr/local/apache --enable-module=so
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093257612.gif[/img]
[size=14px] 5.编译
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093257613.gif[/img]
[size=14px] 6.编译安装
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093257614.gif[/img]
[size=14px] 7.启动服务
[size=14px] /usr/local/apache/bin/apachectl start
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093257615.gif[/img]

[size=14px]三、PHP的安装
[size=14px] 1.下载文件(前面过程基本上同上面的一样)
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093258616.gif[/img]
[size=14px] 2.解压缩文件
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093258617.gif[/img]
[size=14px] 3.进入源码目录
[size=14px] 4.编译前准备
[size=14px] ./configure --prefix=/usr/local/php --with-mysql --with-apxs2=/usr/local/apache/bin/apxs
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093258618.gif[/img]
[size=14px] 5.编译
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093258619.gif[/img]
[size=14px] 6.编译安装
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093258620.gif[/img]
[size=14px] 7.复制PHP配置文件
[size=14px] cp /root/php-版本(源码目录)/php.ini-dist /usr/local/lib/php.ini
[size=14px] 8.修改apache配置文件,使其识别以.php结尾的网页文件
[size=14px] vi /usr/local/apache/conf/httpd.conf
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093258621.gif[/img]
[size=14px] 想文件中插入下面的语句:
[size=14px] AddType application/x-httpd-php .php
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093259622.gif[/img]
[size=14px] 保存退出
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093259623.gif[/img]
[size=14px] 9.安装完成,验证 vi /usr/local/apache/htdocs/index.php
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093259624.gif[/img]
[size=14px]
[size=14px] 保存退出
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093259625.gif[/img]
[size=14px] 最后重新启动一下apache服务即可。
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093259626.gif[/img]
[size=14px]四、实验验收结果
[size=14px]在Windows上访问一下Linux搭建的网站,因为没有建DNS,只能用IP访问
[size=14px]
[color=#044b6][size=14px]http://192.168../index.php
[img=0,20]http://www.datahf.net/zyfiles/cusjhf/20090511Pic/20090511093300627.gif[/img]

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】