[b]一、软件及系统版本[/b]
[img]http://files.jb51.net/file_images/article/201611/20161114144110230.jpg?20161014144121[/img]
系统下载地址:
软件包下载地址:[url=http://xiazai.jb51.net/201611/yuanma/php+apache+mysql(jb51.net).rar]http://xiazai.jb51.net/201611/yuanma/php+apache+mysql(jb51.net).rar[/url]
[b]二、 下载软件包/换源[/b]
[b](1)下载安装需要软件包软件工具[/b]
yum install -y wget vim unzip zip
[img]http://files.jb51.net/file_images/article/201611/201611141439071.png[/img]
[b](2)换源
[/b]
1、首先卸载以前装的epel 以免影响
rpm -e epel-release
2、清空yum缓存
yum clean all
[img]http://files.jb51.net/file_images/article/201611/201611141439072.png[/img]
yum makecache
3、rm -rf /etc/yum.repos.d/*(执行此操作的时候记得事先装好wget 不然 你就得挂载光盘用rpm装wget了。)
[img]http://files.jb51.net/file_images/article/201611/201611141439083.png[/img]
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
[img]http://files.jb51.net/file_images/article/201611/201611141439084.png[/img]
[b]三、 安装mysql[/b]
[b](1)解压[/b]
tar -zxvf mysql-5.1.72-linux-x86_64-glibc23.tar.gz
[img]http://files.jb51.net/file_images/article/201611/201611141439085.png[/img]
(2)配置mysql
mv 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 $?
[img]http://files.jb51.net/file_images/article/201611/201611141439086.png[/img]
(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
[b]四、 安装Apache[/b]
[b](1)安装软件运行环境gcc[/b]
yum install -y gcc
[img]http://files.jb51.net/file_images/article/201611/201611141439087.png[/img]
[b](2)解压[/b]
tar -jxvf httpd-2.2.27.tar.bz2
[img]http://files.jb51.net/file_images/article/201611/201611141439088.png[/img]
[b](3)编译[/b]
./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --enable-so
[img]http://files.jb51.net/file_images/article/201611/201611141439089.png[/img]
[b](4)安装[/b]
make
[img]http://files.jb51.net/file_images/article/201611/2016111414390810.png[/img]
make install
[img]http://files.jb51.net/file_images/article/201611/2016111414390811.png[/img]
[b]五、 安装PHP[/b]
[b](1)解压[/b]
tar -zxvf php-5.3.28.tar.gz
[b][img]http://files.jb51.net/file_images/article/201611/2016111414390812.png[/img]
[/b]
[b](2)安装php所需软件插件[/b]
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
[b][img]http://files.jb51.net/file_images/article/201611/2016111414390913.png[/img]
(3)编译[/b]
./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
[b][img]http://files.jb51.net/file_images/article/201611/2016111414390914.png[/img]
[/b]
[b](4)安装[/b]
make
[b][img]http://files.jb51.net/file_images/article/201611/2016111414390915.png[/img]
[/b]
make install
[b][img]http://files.jb51.net/file_images/article/201611/2016111414390916.png[/img]
[/b]
[b]六、编辑配置文件[/b]
(1)vim /usr/local/apache2/conf/httpd.conf找到:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
改为:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
将该行改为:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80
2 测试解析php
vim /usr/local/apache2/htdocs/1.php
写入:
浏览器打开:地址/1.php
[img]http://files.jb51.net/file_images/article/201611/20161114151247588.jpg?20161014151320[/img]
自此php环境安装完成
注:1.安装期间需要系统联网,若无法联网,可下载相关rpm包进行安装。(我自己都是通过虚拟机做成模板直接导入的,若不是虚拟环境可选之前的方法)
2.apache没有做成服务,Apache做服务会在下一篇介绍,另外mysql安装完成后是没有密码的,可自行设置。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。