开始安装apache2.4.3:
解包,进入源码包
[iyunv@localhost httpd-2.4.3]# ./configure \
> –prefix=/usr/local/apache243 \
> –enable-mods-shared=all \
> –enable-deflate \
> –enable-speling \
> –enable-cache \
> –enable-file-cache \
> –enable-disk-cache \
> –enable-mem-cache \
> –enable-so \
> –enable-expires=shared \
> –enable-rewrite=shared \
> –enable-static-support \
> –sysconfdir=/etc/httpd \
> –with-z=/usr/local/zlib/ \
> –with-apr=/usr/local/apr-httpd/ \
> –with-apr-util=/usr/local/apr-util-httpd/ \
> –with-pcre=/usr/local/pcre/ \
> –disable-userdir
#make && make install
安装完成后,进入/usr/local/apache243/目录下,检查是否有以下文件:
bin build cgi-bin error htdocs icons include logs man manual modules
启动Apache服务器,并查端口是否开启,启动Apache服务器的命令行如下:
#/usr/local/apache243/bin/apachectl start
提示信息:
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using ::1. Set the ’ServerName’ directive globally to suppress this message
解决方案:
vi /etc/httpd/httpd.conf
加上下面一行,重启apache
ServerName localhost:80
查看端口命令行如下:
#netstat -tnl|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LIST
测试安装结果,打开浏览器,在地址栏中输入URL为:http://192.168.146.129/
如果浏览器中出现It works!则表明Apache服务器可以使用。
每种服务器软件都有必要制成开机时自动启动,Apache服务器开机自动启动,只要在“/etc/rc.d/rc.local”文件,加上 Apache服务器的启动命令即可。可以直接打开“/etc/rc.d/rc.local”文件,在最后一行写入Apache启动命令,也可以用echo 命令追加进去,如下命令行示:
[iyunv@localhost apache243]# echo ”/usr/local/apache243/bin/apachectl start” >> /etc/rc.d/rc.local
注意需要开启相应的防火墙端口:
1、开启端口(以80端口为例)
方法一:
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 写入修改
/etc/init.d/iptables save 保存修改
service iptables restart 重启防火墙,修改生效
方法二:
vi /etc/sysconfig/iptables 打开配置文件加入如下语句:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 重启防火墙,修改完成
2、关闭端口
方法一:
/sbin/iptables -I INPUT -p tcp --dport 80 -j DROP 写入修改
/etc/init.d/iptables save 保存修改
service iptables restart 重启防火墙,修改生效
方法二:
vi /etc/sysconfig/iptables 打开配置文件加入如下语句:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j DROP 重启防火墙,修改完成
3、查看端口状态
/etc/init.d/iptables status
安装mysql.5.5.39
此前需要先,创建安装目录,数据存放目录,用户权限等,以及编译安装cmake....
1 建立mysql安装目录及数据存放目录
# mkdir /usr/local/mysql
# mkdir /var/mysqldata
2 创建用户和用户组
# groupadd mysql
# useradd -g mysql mysql
3 赋予数据存放目录权限
# chown mysql.mysql –R /var/mysqldata/
4 安装cmake
mysql5.5以后是通过cmake来编译的
通过以下路径下载cmake-2.8.4.tar.gz,也可在http://www.cmake.org网站进行下载
# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
# ./bootstrap
# gmake && gmake install
5.解压进包:
# tar zxvf mysql-5.5.21.tar.gz
# cd mysql-5.5.21
3、 设置MySQL远程连接
1) mysql 数据库端设置
# /mysql -u root -p //进入数据库
mysql>use mysql
mysql>select user,password,host from user;
mysql>update user set host = '192.168.%' where user = '127.0.0.1';
mysql>grant all privileges on *.* to root@'%' identified by "root123";//给以root@ip登录的远程连接赋予权
进入php-5.4.11源码包编译
[iyunv@localhost php-5.4.11]# ./configure \
> –prefix=/usr/local/php \
> –with-config-file-path=/usr/local/php/etc \
> –with-apxs2=/usr/local/apache243/bin/apxs \
> –with-mysql=/usr/local/mysql/ \
> –with-libxml-dir=/usr/local/libxml2/ \
> –with-png-dir=/usr/local/libpng/ \
> –with-jpeg-dir=/usr/local/jpeg8/ \
> –with-freetype-dir=/usr/local/freetype/ \
> –with-gd=/usr/local/gd/ \
> –with-zlib-dir=/usr/local/zlib/ \
> –with-mcrypt=/usr/local/libmcrypt/ \
> –with-mysqli=/usr/local/mysql/bin/mysql_config \
> –enable-soap \
> –enable-mbstring=all \
-enbale-so
> –enable-sockets
make(配置)
提示信息:
Build complete.
Don’t forget to run ’make test’.
解决方案:
不要make test 直接make install
配置时可能会出现下面的错误:
checking for MySQL support… yes
checking for specified location of the MySQL UNIX socket… no
checking for MySQL UNIX socket location… no
configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!
其实这跟PHP没有关系,那是因为在编译APACHE的时候,使用–with-mpm模块,所以就必须在编译MYSQL的时候加上 –enable-thread-safe-client.参数
这是PHP5.2的一个改进,在PHP5.2.0之前的版本都不需要MYSQL启用安全线程。关于–enable-thread-safe- client项的官方介绍如下:如何生成线程式客户端库总是线程安全的。最大的问题在于从套接字读取的net.c中的子程序并不是中断安全的。或许你可能 希望用自己的告警中断对服务器的长时间读取,以此来解决问题。如果为SIGPIPE中断安装了中断处理程序,套接字处理功能应是线程安全的。 SupeSite/X-为了避免连接中断时放弃程序,MySQL将在首次调用mysql_server_init()、mysql_init()或 mysql_connect()时屏蔽SIGPIPE。如果你打算使用自己的SIGPIPE处理程序,首先应调用 mysql_server_init(),然后安装你的处理程序.
还有第二种解决方法比较方便 :编译之前,先处理一下mysql的库,默认查找libmysqlclient_r.so,可是mysql默认为libmysqlclient.so,内容完全一样,做个链接即可
# cd /usr/local/mysql/lib/mysql/
# ln -s libmysqlclient.so.15.0.0 libmysqlclient_r.so
(以上解决方法来自互联网!)
还会报make: *** [ext/gd/gd.lo] error
解决方法如下:
好像说这个错误算是php5.4的bug,下面对应的两篇文章有对应的说明:
https://bugs.php.net/bug.php?id=55224
https://bugs.php.net/bug.php?id=60108
解决方法:
vi <gd_dir>/include/gd_io.h
gdIOCtx结构中增加void *data;
格式如下
typedef struct gdIOCtx
{
int (*getC) (struct gdIOCtx *);
int (*getBuf) (struct gdIOCtx *, void *, int);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *);
void (*data);
}
gdIOCtx;
我的GD安装在/usr/local/gd2目录下,所以是#vi vi /usr/local/gd/include/gd_io.h
libltdl.so.3: cannot open shared object file: No such file or directory
make: *** [ext/phar/phar.php] Error 127
解决方法:
ln -s /usr/local/lib/libltdl.so.3 /usr/lib/libltdl.so.3
[iyunv@localhost ~]# cd /usr/local/libpng/lib/
[iyunv@localhost lib]# ls
libpng15.a libpng15.so libpng15.so.15.10.0 libpng.la pkgconfig
libpng15.la libpng15.so.15 libpng.a libpng.so
可以看到libpng15.so.15
然后修改/etc/ld.so.conf 文件:vi /etc/ld.so.conf
在第一行下面追加/usr/local/libpng/lib这个路径。
然后重新编译安装即可。
提示信息:
=====================================================================
=====================================================================
WARNED TEST SUMMARY
———————————————————————
Bug #52062 (large timestamps with DateTime::getTimestamp and DateTime::setTimestamp) (32 bit) [ext/date/tests/bug52062.phpt] (warn: XFAIL section but test passes)
=====================================================================
You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP’s behavior.
If you don’t want to send the report immediately you can choose
option ”s” to save it. You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]:
解决方案:
不要make test 直接make install
安装完成后,需要建立PHP配置文件。在使用configure命令安装配置时使用“–with-config-file-path=/usr /local/php/etc/”选项,指定了配置文件的位置。将源码包下面的php.ini-development 文件复制到/usr/local /php/etc/中,并改名为php.ini即可,如下示:
[iyunv@localhost php-5.4.11]# cp php.ini-development /usr/local/php/etc/php.ini
修改php.ini 把;date.timezone 前面的分号去掉,改成date.timezone =”PRC”
整合Apache与PHP,上面编译之前,我们使用configure命令安装配置时,使用–with-apxs2=/usr/local /apache242/bin/apxs选项以使Apache 2将PHP作为功能模块使用。但我们还要修改Apahce配置文件,添加PHP的支持,告 诉Apache将哪些后缀作为PHP解析。例如,让Apache把.php或.phtml后缀名解析为PHP.使用vi打开Apache的配置文件 /etc/httpd/httpd.conf,找到AddType application/x-gzip .gz .tgz指令选项,并在其下方添加一 条指令AddType application/x-httpd-php .php .phtml。也可以将任何后缀的文件解析为PHP,只要在添加的语 句中加入并用空格分开,这里以多添加一个.phtml来示例,如下示:
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml
修改完成后必须重启Apache服务器,才能重新加载配置文件使修改生效。
[iyunv@localhost php-5.4.11]#/usr/local/apache243/bin/apachectl stop
[iyunv@localhost php-5.4.11]#/usr/local/apache243/bin/apachectl start
测试PHP环境是否可以正常运行,在/usr/local/apache243/htdocs目录下建一个test.php或test.phtml的文件,内容如下示:
<?php
phpinfo();
?>
打开浏览器,在地址栏输入http://192.168.146.129/test.php来运行该文件,如果出现下图内容,说明LAMP环境安装成功。