php httpd mysql_PHP环境搭建(php+Apache+mysql) 的详细介绍

一、软件及系统版本

b7bca895234780a7f630650032295011.png

系统下载地址:

软件包下载地址:http://xiazai.jb51.net/201611/yuanma/php+apache+mysql(jb51.net).rar

二、 下载软件包/换源

(1)下载安装需要软件包软件工具

yum install -y wget vim unzip zip

e5b6a3f81f7e05cacb474b981ec09744.png

(2)换源

1、首先卸载以前装的epel 以免影响

rpm -e epel-release

2、清空yum缓存

yum clean all

1ddc59aab3b09cbeaa06327563c46c38.png

yum makecache

3、rm -rf /etc/yum.repos.d/*(执行此操作的时候记得事先装好wget 不然 你就得挂载光盘用rpm装wget了。)

a7a973a10fee657e02623b5ac4f1438b.png

4、下载阿里源

wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repohttp://mirrors.aliyun.com/repo/Centos-6.repo

5、

yum repolist

681f223416a908bb943dcb29c8b67b1d.png

三、 安装mysql

(1)解压

tar -zxvf mysql-5.1.72-linux-x86_64-glibc23.tar.gz

eb512d1af11901a2910d65b884cf47cc.png

(2)配置mysqlmv mysql-5.1.72-linux-x86_64-glibc23 /usr/local/mysql

cd /usr/local/mysql

useradd -s /sbin/nologin mysql

mkdir -p /data/mysql

chown -R mysql:mysql /data/mysql

./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

检查是否编译成功

echo $?

196c0c5ec5a5118e39f83e30aabd44cb.png

(3)将mysql做成服务cp support-files/my-large.cnf /etc/my.cnf

cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

vim /etc/init.d/mysqld

修改文件内容

basedir=/usr/local/mysql(mysql安装目录)

datadir=/data/mysqlmysql数据库目录)

chkconfig --add mysqld

chkconfig mysqld on

四、 安装Apache

(1)安装软件运行环境gcc

yum install -y gcc

eaca5a7d57a300cf608b805d8981280f.png

(2)解压

tar -jxvf httpd-2.2.27.tar.bz2

d23d4f5972d8ae4df64f9ec83328bc03.png

(3)编译

./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-so

9ee8b1f0d08c49da44ab28662fe36413.png

(4)安装

make

9444933c6d796602b9490538a4b9feba.png

make install

90319badfbbf23f08bc6a3dc9be9781d.png

五、 安装PHP

(1)解压

tar -zxvf php-5.3.28.tar.gz

efbff7018dc628de61385cd6521d39ad.png

(2)安装php所需软件插件yum install -y libxml2-devel.x86_64

yum install -y openssl-devel.x86_64

yum install -y bzip2-devel.x86_64

yum install -y libjpeg-turbo-devel.x86_64

yum install -y libpng-devel.x86_64

yum install -y freetype-devel.x86_64

yum install -y libmcrypt-devel.x86_64

26e1236ff6eae3ea806a6670b5edaa89.png

(3)编译./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

--with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql

--with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir

--with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf

--enable-mbstring --enable-sockets --enable-exif --disable-ipv6

56a66909027a49c8771b84dfae14a81a.png

(4)安装

make

541c258dcb138acfb2f7fd300e9a0652.png

make install

dc7af6c974bf4a4094501ef9cd12a507.png

六、编辑配置文件

(1)vim /usr/local/apache2/conf/httpd.conf找到:

Options FollowSymLinks

AllowOverride None

Order deny,allow

Deny from all

改为:

Options FollowSymLinks

AllowOverride None

Order deny,allow

Allow from all

找到:

AddType application/x-gzip .gz .tgz

在该行下面添加:

AddType application/x-httpd-php .php

找到:

DirectoryIndex index.html

将该行改为:

DirectoryIndex index.html index.htm index.php

找到:

#ServerName www.example.com:80

修改为:

ServerName localhost:80

2 测试解析php

vim /usr/local/apache2/htdocs/1.php

写入:<?php

phpinfo();

?>

浏览器打开:地址/1.php

ae11b8e7838529a3741830e67428f634.png

自此php环境安装完成

注:1.安装期间需要系统联网,若无法联网,可下载相关rpm包进行安装。(我自己都是通过虚拟机做成模板直接导入的,若不是虚拟环境可选之前的方法)

2.apache没有做成服务,Apache做服务会在下一篇介绍,另外mysql安装完成后是没有密码的,可自行设置。

以上就是PHP环境搭建(php+Apache+mysql) 的详细介绍的内容,更多相关内容请关注PHP中文网(www.php.cn)!

f68f2add0b68e4f9810432fce46917b7.png

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值