lnmp笔记php5.2

centos6.3

apache2.2

mysql5.1

php5.2.17

安装gcc、gcc-c++编译器

yum -y install gcc*

卸载默认的低版本环境 http mysql

关闭selinxu

安装

1、安装libxml2

# cd /usr/local/src/libxml2-2.6.30

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

# make && make install

2、安装libmcrypt

# cd /usr/local/src/libmcrypt-2.5.8

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

# make && make install

3、安装zlib

# cd /usr/local/src/zlib-1.2.3

# ./configure

# make && make install

4、安装libpng

# cd /usr/local/src/libpng-1.2.31

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

# make && make install

5、安装jpeg6

这个软件包安装有些特殊,其它软件包安装时如果目录不存在,会自动创建,但这个软件包安装时需要手动创建。

# mkdir /usr/local/jpeg6

# mkdir /usr/local/jpeg6/bin

# mkdir /usr/local/jpeg6/lib

# mkdir /usr/local/jpeg6/include

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

# cd /usr/local/src/jpeg-6b

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

# make && make install

6、安装freetype

# cd /usr/local/src/freetype-2.3.5

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

# make

# make install

7、安装autoconf

# cd /usr/local/src/autoconf-2.61

# ./configure

# make && make install

8、安装GD库

# cd /usr/local/src/gd-2.0.35

# ./configure \

--prefix=/usr/local/gd2/ \

--enable-m4_pattern_allow \

--with-zlib=/usr/local/zlib/ \

--with-jpeg=/usr/local/jpeg6/ \

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

--with-freetype=/usr/local/freetype/

# make

出现错误:

make[2]: *** [gd_png.lo] Error 1

make[2]: Leaving directory `/usr/local/src/gd-2.0.35'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/usr/local/src/gd-2.0.35'

make: *** [all] Error 2

分析:这个问题是因为gd库中的gd_png.c这个源文件中包含png.h时,png.h没有找到导致的。

解决:

在编译文件里

# vi gd_png.c

将include “png.h” 改成 include “/usr/local/libpng/include/png.h”

其中/usr/local/libpng/为libpng安装路径。

# make install

9、安装Apache

# cd /usr/local/src/httpd-2.2.9

# ./configure \

--prefix=/usr/local/apache2 \

--sysconfdir=/etc/httpd \

--with-z=/usr/local/zlib \

--with-included-apr \

--enable-so \

--enable-deflate=shared \

--enable-expires=shared \

--enable-rewrite=shared \

--enable-static-support

# make && make install

10、配置Apache

启动Apache

# /usr/local/apache2/bin/apachectl start

关闭Apache

# /usr/local/apache2/bin/apachectl stop

查看80端口是否开启

# netstat -tnl|grep 80

访问Apache服务器

添加自启动

# echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local

11、安装Mysql

添加一个mysql标准组

# groupadd mysql

添加mysql用户并加到mysql组中

# useradd -g mysql mysql

# cd /usr/local/src/mysql-5.0.41

# ./configure \

--prefix=/usr/local/mysql/ \

--with-extra-charsets=all

出现错误:

checking for tgetent in -lncurses... no

checking for tgetent in -lcurses... no

checking for tgetent in -ltermcap... no

checking for tgetent in -ltinfo... no

checking for termcap functions library... configure: error: No curses/termcap library found

分析:缺少ncurses安装包

解决:

# yum install ncurses-devel

# make && make install

2、配置Mysql

创建MySQL数据库服务器的配置文件

# cp support-files/my-medium.cnf /etc/my.cnf

用mysql用户创建授权表,创建成功后,会在/usr/local/mysql目录下生成一个var目录

# /usr/local/mysql/bin/mysql_install_db --user=mysql

将文件的所有属性改为root用户

# chown -R root /usr/local/mysql

将数据目录的所有属性改为mysql用户

# chown -R mysql /usr/local/mysql/var

将组属性改为mysql组

# chgrp -R mysql /usr/local/mysql

启动数据库

# /usr/local/mysql/bin/mysqld_safe --user=mysql &

查看3306端口是否开启

# netstat -tnl|grep 3306

简单的测试

# /usr/local/mysql/bin/mysqladmin version

查看所有mysql参数

# /usr/local/mysql/bin/mysqladmin variables

设置Mysql开机自启动

# cp /usr/local/src/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld

# chown root.root /etc/rc.d/init.d/mysqld

# chmod 755 /etc/rc.d/init.d/mysqld

# chkconfig --add mysqld

# chkconfig --list mysqld

# chkconfig --levels 245 mysqld off

14、安装PHP

# cd /usr/local/src/php-5.2.6

# ./configure \

--prefix=/usr/local/php \

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

--with-apxs2=/usr/local/apache2/bin/apxs \

--with-mysql=/usr/local/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=/usr/local/mysql/bin/mysql_config \

--enable-soap \

--enable-mbstring=all \

--enable-sockets

# make && make install

报错

make: *** [ext/dom/node.lo] Error 1

在国外的一个网站上找到了这个,其他版本的php也同样适用。

# curl -o php-5.x.x.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt

# cd php-5.x.x

# patch -p0 -b < ./php-5.x.x.patch

  patching file ext/dom/node.c

  patching file

  ext/dom/documenttype.c

  patching file ext/simplexml/simplexml.c

再次编译即可。

创建配置文件

# cp php.ini-dist /usr/local/php/etc/php.ini

使用vi编辑apache配置文件

# vi /etc/httpd/httpd.conf

添加这一条代码

Addtype application/x-httpd-php .php .phtml

重启Apache

# /usr/local/apache2/bin/apachectl restart

测试

运维QQ交流群:171586999

你可能感兴趣的:(lnmp笔记php5.2)