yum install wget make gcc gcc-c++ pcre openssl openssl-devel zlib unzip cmake ncurses-devel libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-devel curl-devel libtool libtool-ltdl libtool-ltdl-devel libevent libevent-devel zlib-static zlib-devel autoconf pcre-devel gd perl freetype freetype-devel

安装apr

tar -zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./buildconf
./configure --prefix=/usr/local/apr/
make 
make install

安装apr-util

tar -zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make 
make install

安装apache

groupadd www
useradd -g www www -s /bin/false

# 下载apache2.2.31
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.2.31.tar.gz

# 解压缩
tar -zxvf httpd-2.2.31.tar.gz

# 进入源码目录
cd httpd-2.2.31

# 开始配置
./configure --prefix=/usr/local/httpd/ \
--sysconfdir=/etc/httpd/ \
--with-include-apr \
--disable-userdir \
--enable-so \
--enable-defate=shared \
--enable-expires-shared \
--enable-rewrite=shared \
--enable-static-support \
--with-apr=/usr/local/apr/ \
--with-apr-util=/usr/local/apr-util/bin \
--with-ssl \
--with-z \

# 执行make安装
make
make install

配置Apache httpd.conf

# 打开配置文件
vim /etc/httpd/httpd.conf

# 修改
#ServerName www.example.com:80 改 ServerName locahost:80

增加apache环境变量

vim /etc/profile
# 在文件里增加以下内容($PATH后面是apache安装路径)
export PATH=$PATH:/usr/local/httpd/bin/
# 立即生效
source /etc/profile

配置Apache开机启动

cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
修改你的vim /etc/init.d/httpd脚本 在开始处#!/bin/bash之后的行后插入
# chkconfig: 345 61 61
# description:Apache httpd

# 增加服务
chkconfig --add httpd
chkconfig --level 2345 httpd on

启动apache

service httpd start
错误:httpd:httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
解决:
1、[root@localhost ~]# vi /etc/sysconfig/network          // 查看本机主机名(HOSTNAME选项为主机名)
2、[root@localhost ~]# vi /etc/hosts                            // 配置host文件
在文件中加入:127.0.0.1       localhost.localdomain
3、[root@localhost ~]# service httpd start                    // 重启apache服务


vim /etc/httpd/httpd.conf
修改ServerName为localhost并取消注释
修改用户和用户组,把user=deamon group=deamon 改成 user=www group=www

启动          /usr/local/apache/bin/apachectl -f /usr/local/apache/conf/httpd.conf
暴力停止     /usr/local/apache/bin/apachectl -k stop
优雅停止     /usr/local/apache/bin/apachectl -k graceful-stop
优雅的重启     /usr/local/apache/bin/apachectl -k graceful
暴力重启     /usr/local/apache/bin/apachectl -k restart

PHP 编译依赖包安装

# 注意:freetype在生成验证码图片需要用,所以必须要安装的
[root@iZ23g4snm6gZ soft]# yum install openssl-devel  libxml2 libxml2-devel curl-devel  libevent
[root@iZ23g4snm6gZ soft]# yum install libpng libpng-devel libjpeg libjpeg-devel freetype-devel gd gd-devel 

# 源码包安装libiconv
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14/
./configure --prefix=/usr/local/libiconv
make
make install

# 源码包安装libiconv
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=/usr/local/libmcrypt/
make
make install

开始编译PHP(Apache)

# 解压缩
tar -zxvf php-5.6.3.tar.gz
cd php-5.6.3

# 配置
./configure --prefix=/usr/local/php/ \
--with-config-file-path=/usr/local/php/etc/ \
--with-apxs2=/usr/local/httpd/bin/apxs \
--enable-fpm \
--with-zlib \
--with-libxml-dir \
--enable-sockets \
--with-curl \
--with-jpeg-dir \
--with-png-dir \
--with-gd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir= \
--enable-gd-native-ttf \
--with-xmlrpc \
--with-openssl \
--with-mhash \
 --with-mcrypt=/usr/local/libmcrypt/ \
--with-pear \
--enable-mbstring \
--enable-sysvshm \
--enable-zip \
--with-mysql=/usr/local/mysql/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock \
--with-pdo-mysql \
--disable-fileinfo \

make
make install

编辑PHP配置文件

# 复制配置文件
cp /data/soft/php/php-5.6.3/php.ini-production /usr/local/php/etc/php.ini

# 编辑配置文件
vim /usr/local/php/etc/php.ini

设置PHP支持Apache配置文件

# 编辑Apache配置文件
vim /etc/httpd/httpd.conf
# 添加php支持。
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
# 添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”
DirectoryIndex index.html index.php
# 不显示目录结构,找到“Options Indexes FollowSymLinks”,修改为
Options FollowSymLinks
# 开启Apache支持伪静态,找到“AllowOverride None”,修改为
AllowOverride All
# 保存httpd.conf配置,然后再执行以下两行命令
chown -R nobody. /usr/local/apache/htdocs/
chmod -R 777 /usr/local/apache/htdocs/
service httpd restart

YPHP
967 声望77 粉丝

免费好用的素材站:[链接]