Apache编译安装

一.需要软件包

1.apr-1.5.1.tar.gz Linux学习,http:// linux.it.net.cn

2.apr-util-1.5.4.tar.gz

3.pcre-8.20.tar.zip Linux学习,http:// linux.it.net.cn

4.httpd-2.4.10.tar.gz

二. 安装apr

yum install gcc libtools -y
tar zxf apache/apr-1.5.1.tar.gz
cd ./apache/apr-1.5.1
./configure --prefix=/usr/local/apr
make && make install

三.安装apr-util

tar zxf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

四,安装pcre

tar zxf pcre-8.20.tar.gz
cd pcre-8.20
./configure --prefix=/usr/local/pcre
make && make install

五,安装Apache服务器

tar zxf  httpd-2.4.10.tar.gz
cd httpd-2.4.10
./configure--prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre --enable-so --enable-rewrite
make && make install
设置Apache为Linux服务并实现开机自启动
mv /etc/rc.d/init.d/apachectl /etc/rc.d/init.d/httpd
设置Apache为Linux服务并实现开机自启动
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd

MySQL编译安装

一.软件包

mysql-5.6.23.tar.gz

编译安装(注意:由于从新的MySQL5.6开始编译采用CMake 编译参数).所以安装辅助函数库:
yum install ncurses-devel cmake -y

二.新增mysql用户组和用户

groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin

三.编译安装

进入解压后的mysql目录.
cmake  \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/home/data/ \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1
make
make install
出错后重新运行配置,需要删除CMakeCache.txt文件
rm CMakeCache.txt
四.配置
修改mysql安装目录
cd /usr/local/mysql
chown -R mysql:mysql .
修改mysql数据库文件目录
cd /data/mysqldb
chown -R mysql:mysql .
初始化MySQL数据库
cd /usr/local/mysql
scripts/mysql_install_db –user=mysql –datadir=/home/data
复制mysql服务启动配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
(注:如果/etc/my.cnf文件存在,则覆盖。)
复制mysql服务启动脚本及加入PATH路径
cp support-files/mysql.server /etc/init.d/mysqld
vi /etc/profile
#在文件末尾加入
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
#保存退出并运行
source /etc/profile
#重新加载该文件
启动mysql服务并加入开机自启动
service mysqld start
chkconfig mysqld on
检查mysql服务是否启动  netstat -tulnp | grep 3306
设置root的初始密码
mysqladmin -uroot password ‘你的密码’

PHP编译安装

一.软件包

#libmcrypt-2.5.7.tar.gz

#curl-7.40.0.tar.gz

#libpng-1.6.15.tar.gz

#freetype-2.5.4.tar.gz

#libxml2-2.9.2.tar.gz

#gettext-0.19.4.tar.gz

#mhash-0.9.3.tar.gz

#jpegsrc.v6b.tar.gz

#libgd-2.1.0.tar.bz2  #最好用.bz2的用.gz的会在编译PHP时出错

#zlib-1.2.8.tar.gz

#php-5.5.29.tar.gz

二,编译安装zlib

tar zxf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure #zlib不要制定安装路径了

make && make install

三,编译安装libjpeg

tar zxf jpegsrc.v9a.gz

cd jpeg-9a/

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

make && make install

四,编译安装libpng

tar zxf libpng-1.6.15.tar.gz

cd libpng-1.6.15

./configure –prefix=/usr/local/libpng-1

make && make install

五,编译安装freetype

tar zxf  freetype-2.5.4.tar.gz

cd freetype-2.5.4

./configure=/usr/local/freetype

make && make install

六,编译安装libgd

yum install bzip2 -y

tar jxf libgd-2.1.0.tar.bz2

cd libgd-2.1.0

#configure时不要指定prefix了,编译PHP时会出错

./configure  –with-jpeg=/usr/local/libjpeg –with-png=/usr/local/libpng –with-freetype=/usr/local/freetype –with-zlib

make && make install

七,编译安装curl

tar zxf curl-7.40.0.tar.gz

cd curl-7.40.0

./configure –prefix=/usr/local/curl

make && make install

八,编译安装libcrympt

tar zxf libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7

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

make && make install

九,编译安装gettext

tar zxf  gettext-0.19.4.tar.gz

cd gettext-0.19.4

./configure –prefix=/usr/local/gettext

make && make install

十,编译安装libxml2

yum install python-devel -y

tar zxf libxml2-2.9.2.tar.gz

cd libxml2-2.9.2

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

make && make install

十一,编译安装mhash

tar zxf mhash-0.9.3.tar.gz

cd mhash-0.9.3   IT网,http://www.it.net.cn

./configure –prefix=/usr/local/mhash

make && make install

十二,编译安装php

tar zxf  php-5.6.4.tar.gz

cd  php-5.6.4

./configure  \

–prefix=/usr/local/php \

–with-apxs2=/usr/local/apache/bin/apxs \

–enable-calendar \

–with-mysql=/usr/local/mysql \

–with-pdo-mysql=/usr/local/mysql/bin/mysql_config \

–enable-mbstring \

–with-curl=/usr/local/curl \

–enable-exif \

–with-gd \

–with-zlib \

–with-jpeg-dir=/usr/local/libjpeg \

–with-png-dir=/usr/local/libpng \

–with-freetype-dir=/usr/local/freetype \

–with-libxml-dir=/usr/local/libxml2 \

–enable-gd-native-ttf \

–enable-sockets \

–with-mcrypt=/usr/local/libmcrypt \

–with-gettext=/usr/local/gettext \

–with-mhash=/usr/local/mhash \

–enable-shmop

–enable-fpm

make && make install

十三,配置Apache httpd.conf

要改的有如下几处:

1.# vi  /usr/local/apache/conf/httpd.conf

查找AddType application/x-gzip .gz .tgz

在其下加入

AddType application/x-tar .tgz

AddType application/x-httpd-php .php

AddType image/x-icon .ico

2.修改DirectoryIndex 行,添加index.php

修改为DirectoryIndex  index.php  index.html

重启apache服务器: service httpd restart

十四,修改php.ini

找到timezone,修改为timezone=Asia/Shanghai

十五,测试

#再Apache服务器根路径新建index.php文件如下

cd /home/htdocs/

vi index.php

<?php

phpinfo();

?>


发表评论

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


*