图片 2

RHEL5下Apache 2.2 + mysql 5+php5+gd2详细配

接触 solaris : 安装 apache + php + mysql

 一、    安装环境
          1.  
 操作系统:Linux Redhat
AS 5 (安装包定制:开发全选、服务器一个不选)
          2.    数据库 :  MySQL 5.0.45
          3.    Web服务器:
Apache 2.2.8
          4.    脚本语言:PHP 5.2.6
      二、    准备软件:
          1.    httpd-2.2.8.tar.gz
          2.    mysql-5.0.45.tar.gz
          3.    freetype-2.3.5.tar.gz
          4.    jpegsrc.v6b.tar.gz
          5.    libpng-1.2.29.tar.gz
          6.    libxml2-2.6.19.tar.gz
          7.    zlib-1.2.3.tar.gz
          8.    gd-2.0.35.tar.gz
          9.    php-5.2.6.tar.gz
          10.   Zend
          11.   Phpmyadmin
          12.   Phpwind
      三、    安装过程
          1.    安装apache 2.2
              [root@Lamp /]# cd /usr/local/src            
 //进入存放软件包的目录
              [root@Lamp src]# tar zxvf httpd-2.2.8.tar.gz
 //解压缩文件
              [root@Lamp src]# cd httpd-2.2.8
              [root@Lamp httpd-2.2.8]# ./configure 
                                      –prefix=/usr/local/apache 
                                      –enable-mods-shared=all 
                                      –enable-rewrite 
                                      –enable-ssl 
                                      –enable-so
              [root@Lamp httpd-2.2.8]# make
              [root@Lamp httpd-2.2.8]# make install
              [root@Lamp httpd-2.2.8]#
/usr/local/apache/bin/apachectl start
          2.    安装Mysql 5.0.45
              [root@Lamp src]# groupadd mysql
              [root@Lamp src]# useradd -g mysql -s /sbin/nologin -M
mysql
              [root@Lamp src]# tar zxvf mysql-5.0.45.tar.gz
              [root@Lamp src]# cd mysql-5.0.45
              [root@Lamp mysql-5.0.45]# ./configure
–prefix=/usr/local/mysql 
                                                                       
             –with-xcharset=all 
                                                                       
             –with-charset=gbk
              [root@Lamp mysql-5.0.45]# make
              [root@Lamp mysql-5.0.45]# make install
              [root@Lamp mysql-5.0.45]#
/usr/local/mysql/bin/mysql_install_db
              [root@Lamp mysql-5.0.45]# cd /usr/local/mysql/
              [root@Lamp mysql]# chown -R root /usr/local/mysql
              [root@Lamp mysql]# chown -fhv -R mysql:mysql
/usr/local/mysql/var
              [root@Lamp mysql]# chgrp -R mysql /usr/local/mysql
              [root@Lamp mysql]# cp ./share/mysql/my-large.cnf
 /etc/my.cnf
              [root@Lamp mysql]# bin/mysqld_safe –user=mysql
              [root@Lamp mysql]# bin/mysqladmin -u root password
“123456”
        3.安装GD2
          1): 安装zlib
              [root@Lamp mysql]# cd /usr/local/src
              [root@Lamp src]# tar zxvf zlib-1.2.3.tar.gz
              [root@Lamp src]# cd zlib-1.2.3
              [root@Lamp zlib-1.2.3]# ./configure
              [root@Lamp zlib-1.2.3]# make
              [root@Lamp zlib-1.2.3]# make install
          2):安装libxml2
              [root@Lamp src]# tar zxvf libxml2-2.6.19.tar.gz
              [root@Lamp libxml2-2.6.19]# ./configure
–prefix=/usr/local/libxml2
              [root@Lamp libxml2-2.6.19]# make
              [root@Lamp libxml2-2.6.19]# make install
          3):安装Zend
              [root@Lamp src]# cp -r ./Zend /usr/local/
          4):安装libpng
              [root@Lamp src]# tar zxvf libpng-1.2.29.tar.gz
              [root@Lamp libpng-1.2.29]# ./configure
–prefix=/usr/local/libpng
              [root@Lamp libpng-1.2.29]# make
              [root@Lamp libpng-1.2.29]# make install
          5):安装freetype
              [root@Lamp src]# tar zxvf freetype-2.3.5.tar.gz
              [root@Lamp freetype-2.3.5]# ./configure
 –prefix=/usr/local/freetype
              [root@Lamp freetype-2.3.5]# make
              [root@Lamp freetype-2.3.5]# make install
          6):安装jpeg6
              [root@Lamp src]# tar zxvf jpegsrc.v6b.tar.gz
              [root@Lamp jpeg-6b]# ./configure
–prefix=/usr/local/jpeg
              [root@Lamp jpeg-6b]# make
              [root@Lamp /]# mkdir /usr/local/jpeg
              [root@Lamp /]# mkdir /usr/local/jpeg/lib
              [root@Lamp /]# mkdir /usr/local/jpeg/include
              [root@Lamp /]# mkdir /usr/local/jpeg/bin
              [root@Lamp /]# mkdir /usr/local/jpeg/man
              [root@Lamp /]# mkdir /usr/local/jpeg/man/man1
              [root@Lamp jpeg-6b]# make install-lib
              [root@Lamp jpeg-6b]# make install
          7):安装GD2
              [root@Lamp src]# tar zxvf gd-2.0.35.tar.gz
              [root@Lampgd-2.0.35]#./configure
–prefix=/usr/local/gd 
                                                                       
     –with-jpeg=/usr/local/jpeg 
                                                                       
     –with-freetype=/usr/local/freetype 
                                                                       
     –with-png=/usr/local/libpng 
                                                                       
     –with-zlib
              [root@Lamp gd-2.0.35]# make
              [root@Lamp gd-2.0.35]# make install
          8):创建 mmcache 目录
              [root@Lamp src]# mkdir /tmp/mmcache
              [root@Lamp src]# chmod 777 /tmp/mmcache
      四、    安装php-5.2.6
              [root@Lamp src]# tar zxvf php-5.2.6.tar.gz
              [root@Lamp php-5.2.6]# ./configure
                                    –prefix=/usr/local/php 
                                   
–with-apxs2=/usr/local/apache/bin/apxs 
                                    –with-mysql=/usr/local/mysql 
                                    –with-libxml=/usr/local/libxml2 
                                   
–with-config-file-path=/usr/local/Zend/etc 
                                    –with-gd=/usr/local/gd 
                                   
–with-freetype-dir=/usr/local/freetype/ 
                                    –with-jpeg-dir=/usr/local/jpeg/ 
                                    –with-png-dir=/usr/local/libpng/ 
                                    –with-zlib-dir 
                                    –enable-mbstring 
                                    –enable-sockets
            [root@Lamp php-5.2.6]# make
            [root@Lamp php-5.2.6]# make install
            [root@Lamp php-5.2.6]# cp php.ini-dist
/usr/local/php/lib/php.ini
      五、    修改httpd.con让apache 支持PHP5
            [root@Lamp conf]# vi /usr/local/apache/conf/httpd.conf
            *在LoadModule处添加 LoadModule php5_module
module/libphp5.so
            *在DirectoryIndex处添加 index.php
            *在AddType application处添加
                AddType application/x-httpd-php .php .phtml
                AddType applicatoin/x-httpd-php-source .phps
      六、    测试Apache ,php是否正常运行。
            [root@Lamp htdocs]# vi
/usr/local/apache/htdocs/test.php
              具体语句:  <?
                            phpinfo()
                            ?>
              Apache
              Php    
可以看到php信息说明正常!

首先确保系统可以联网。设置IP地址以及虚拟机安装linux在此略过。本文采用centos6.7
64位minimal版、php5.6.16、httpd-2.4.18、mysql-5.5.47版搭建lamp环境。默认设置软件下载目录/usr/local/src,软件安装目录/app/local/下,安装顺序是apache→mysql→php。通过搜狐镜像获取apache、mysql、php
搜狐镜像:

这是最简单的安装,请扩展成自己需要的


wget

-y install wget

作者信息 ================================= Macro Zeng

wget

Before Start ======================================= install gtar :
install gcc : gcc-2.8.1-sol7-sparc-local install gzip :
gzip-1.3-sol7-sparc-local install make : make-3.77-sol7-sparc-local
install gd 1.8.3 : install autoconf-2.13-sol7-sparc-local; install
perl-5.005_02-sol7-sparc-local gd-1.8.3.tar.gz
zlib-1.1.3-sol7-sparc-local.gz jpeg-6b-sol7-sparc-local.gz
libpng-1.0.2-sol7-sparc-local.gz xpm-3.4k-sol7-sparc-local.gz

wget

Mysql ======================================= pkgadd -d
mysql-3.23.28-gamma-sun-solaris2.7-sparc (进入解包后的目录)
./scripts/mysql_install_db

wget

PHP ======================================= cd apache_1.3.14
./configure –prefix=/usr/local/apache_php /** * this step need 1
minutes **/ cd ../php-4.0.3pl1 ./configure –prefix=/usr/local/php
–with-apache=../apache_1.3.14 –with-mysql=/usr/local/mysql

wget

–with-ftp –with-xml –enable-track-vars /** * NOTE:You must install
gd lib before you use –with-gd * this step need 2 minutes **/ make
/** * If not find libtool,you must redirector the make path to
/usr/css/bin * successful message : Making all in pear * this step
need 5 minutes **/ make install /** * successful message : done *
this step need 1 minutes * creat the /usr/local/php directory **/

wget

Apache ======================================= cd ../apache_1.3.14
./configure –prefix=/usr/local/apache_php
–activate-module=src/modules/php4/libphp4.a /** * successful message
: Creating Makefile in src/… * this step need 2 minutes **/ make
/** * successful message : <=== src/support <=== src * this
step need 1 minutes **/ make install /** * successful message :
<=== [config] * this step need 1 minutes * creat the
/usr/local/apache_php directory **/

wget

Others ====================================== cd ../php-4.0.3pl1 cp
php.ini-dist /usr/local/lib/php.ini /** * modify
/usr/local/apache_php/conf/ * modify /usr/local/lib/php.ini **/

wget
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

wget ftp://ftp.cn.debian.org/gentoo/distfiles/zlib-1.2.5.1.tar.gz

wget

wget

wget

wget

wget

wget

wget

wget

首先安装相应的库文件:
yum -y install xz  libXpm-devel lua-devel libxslt-devel gcc
gcc-c++libjpeg libjpeg-devel glibc glibc-devel glib2 glib2-devel bzip2
bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs
e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl
openssl-devel openldap openldap-devel nss_ldap openldap-clients
openldap-servers

新建相应的目录和用户和用户组:

mkdir -p /app/local/{php,apache,mysql,data}
groupadd -g 500 www
useradd -u 500 -g
500 -G 500 -s /sbin/nologin www

groupadd
mysql

useradd -g
mysql mysql -s /bin/false

#cd
/usr/local/src/

#tar zxvf 
apr-1.5.2.tar.gz

#cd
apr-1.5.2

#./configure
–prefix=/usr/local/apr

报错提示:cannot
remove `libtoolT’: No such file or directory ,

解决办法:编辑
configure文件,查找 $RM “$cfgfile”
这个地方,用#注释掉,然后就可以了

#./configure
–prefix=/usr/local/apr

#make &&
make install

#cd
../

#tar zxvf
apr-util-1.5.4.tar.gz

#cd
apr-util-1.5.4

#./configure
–prefix=/usr/local/apr-util
–with-apr=/usr/local/apr/bin/apr-1-config

#make &&
make install

#cd../

#tar zxvf
pcre-8.10.tar.gz

#cd
pcre-8.10

#./configure
–prefix=/usr/local/pcre

#make &&
make install

#cd
../

安装Apache

#tar zxvf
httpd-2.4.18.tar.gz

#cd
httpd-2.4.18

#./configure
–prefix=/app/local/apache –enable-mods-shared=all –enable-so
–enable-proxy-ajp –enable-rewrite –with-apr=/usr/local/apr
–with-apr-util=/usr/local/apr-util
–with-pcre=/usr/local/pcre

#make &&
make install

#cd
../

#chown -R
www:www /app/local/apache/htdocs/

#chmod 755
/app/local/apache/htdocs/

先配置一下httpd.conf
找到;ServerName
www.example.com:80
改为ServerName
localhost:80
#/app/local/apache/bin/apachectl
-k start

在浏览器下输入ip地址查看apache是否成功启动

 

如果没有的话
可能是selinux和防火墙没有做相应设置

 

vi
/etc/sysconfig/iptables

 

在端口22下一行加入80
3306端口配置(分别是apache和mysql的端口)

 

-A INPUT -m
state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

 

-A INPUT -m
state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

 

:wq保存退出

 

service
iptables restart #重启防火墙使配置生效

 

然后在关闭selinux

 

vi
/etc/sysconfig/selinux

 

改为SELINUX=disabled

 

:wq#保存退出

 

setenforce 0
#使配置立即生效

然后安装mysql,首先安装cmake

#tar zxvf cmake-3.1.3.tar.gz

#cd cmake-3.1.3

#./configure

#make && make install

#cd ../

#tar zxvf mysql-5.5.47.tar.gz

#cd mysql-5.5.47

#cmake
-DCMAKE_INSTALL_PREFIX=/app/local/mysql
-DMYSQL_DATADIR=/app/local/data -DSYSCONFDIR=/etc

#make && make install

#cd ../

#chown -R mysql:mysql
/app/local/data

# cp
/app/local/mysql/support-files/my-innodb-heavy-4G.cnf /etc/my.cnf

#ln -s /app/local/mysql/my.cnf
/etc/my.cnf

#cd /app/local/mysql/

#./scripts/mysql_install_db
–user=mysql –basedir=/app/local/mysql –datadir=/app/local/data

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

#chkconfig mysql on

#service mysql start

#cd /usr/local/src

最后安装php

#tar zxvf libxml2-2.7.4.tar.gz

#cd libxml2-2.7.4

#./configure
–prefix=/usr/local/libxml2

报错提示:cannot
remove `libtoolT’: No such file or directory ,

解决办法:编辑
configure文件,查找 $RM “$cfgfile”
这个地方,用#注释掉,然后就可以了

#./configure
–prefix=/usr/local/libxml2

#make && make install

#cd ../

#tar zxvf libmcrypt-2.5.7.tar.gz

#cd libmcrypt-2.5.7

#./configure –prefix=/usr/local/libmcrypt

#make && make install

#cd ../

#tar zxvf zlib-1.2.8.tar.gz

#cd zlib-1.2.8

#./configure

#make && make install

#cd ../

#xz -d libpng-1.2.56.tar.xz

#tar -xvf libpng-1.2.56.tar

#cd libpng-1.2.56

#./configure –prefix=/usr/local/libpng

#make && make install

#cd ../

#mkdir -p /usr/local/jpeg6/{bin,lib,include,man}

#mkdir /usr/local/jpeg6/man/man1

#tar zxvf jpegsrc.v9b.tar.gz

#cd jpeg-9b/

#./configure –prefix=/usr/local/jpeg6/ –enable-shared –enable-static

#make && make install

#cd ../

#tar jxvf freetype-2.4.12.tar.bz2

#cd freetype-2.4.12

#./configure -prefix=/usr/local/freetype

#make && make install

#cd ../

#tar zxvf autoconf-2.53.tar.gz

#cd autoconf-2.53

#./configure

#make && make install

#cd ../

#tar jxvf libgd-2.1.1.tar.bz2

#cd libgd-2.1.1

#./configure –prefix=/usr/local/gd2  –with-zlib=/usr/local/zlib
–with-jpeg=/usr/local/jpeg6 –with-png=/usr/local/libpng
–with-freetype=/usr/local/freetype/

#make && make install

#cd ../

#tar jxvf php-5.6.12.tar.bz2

#cd php-5.6.12

#./configure –prefix=/app/local/php
–with-config-file-path=/app/local/php/etc
–with-apxs2=/app/local/apache/bin/apxs –with-mysql
–with-libxml-dir=/usr/local/libxml2 –with-png-dir=/usr/local/libpng
–with-jpeg-dir=/usr/local/jpeg6 –with-freetype-dir=/usr/local/freetype
–with-gd=/usr/local/gd2 –with-zlib-dir=/usr/local/zlib
–with-mcrypt=/usr/local/libmcrypt –with-mysqli
–with-xpm-dir=/usr/lib64 –enable-soap –enable-mbstring=all
–enable-sockets

#make && make install

#cd ../

#cp
/usr/local/src/php-5.6.12/php.ini-production
/app/local/php/etc/php.ini
#vi
/app/local/php/etc/php.ini
找到;date.timezone
改为date.timezone=PRC
保存退出
配置apache解析php:
#vi
/app/local/apache/conf/httpd.conf

找到;ServerName
www.example.com:80
改为ServerName
localhost:80
找到:AddType
application/x-gzip .gz .tgz
在该行下面添加:AddType
application/x-httpd-php .php
找到DirectoryIndex
index.html 
改为:DirectoryIndex
index.html index.htm index.php
找到User
daemon Group daemon
注释后添加:User
www
 
                  Group www

找到:
Options  Indexes FollowSymLinks
修改为:Options 
 FollowSymLinks
找到:AllowOverride
None
修改为:AllowOverride
All

equire all
granted

最后保存退出#/app/local/apache/bin/apachectl -t#测试httpd.conf
如果有错误,会有提示, 如果是正确的则显示为 “Syntax
OK”

#/app/local/apache/bin/apachectl  start

#ps
-ef|grep
httpd

root    
12130  1259  0 15:49 pts/0    00:00:00 grep httpd
root     23172     1  0 14:13 ?        00:00:00
/app/local/apache/bin/httpd -k start
www      23173 23172  0 14:13 ?        00:00:02
/app/local/apache/bin/httpd -k start
www      23174 23172  0 14:13 ?        00:00:02
/app/local/apache/bin/httpd -k start
www      23175 23172  0 14:13 ?        00:00:02
/app/local/apache/bin/httpd -k
start

说明已经启动
#vi
/app/local/apache/htdocs/info.php

<?php

 

phpinfo();

 

?>

 

保存退出后在浏览器输入ip地址/info.php后检测是否成功

如图所示

图片 1

图片 2

 

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注