Ubuntu下使用源码包搭建LAMP环境错误笔记

1.编译环境错误:

Ubuntu 10.04下仅预装了gcc编译环境,但安装此套环境的源码包还需要g++(即c++)的编译环境,需要安装g++软件,但这两者的版本需要同步,否则安装会出错,比较好的解决方案是使用如下的命令:

sudo apt-get install build-essential

来安装整套编译环境的套装软件(因为单独安装gcc与g++可能引发两者的版本不同步),装好后,编译环境即配置完成

 

2.编译libxml2时出错:

错误信息如下图:

 解决方法:

打开目录下的nanohttp.c,第1588行由 
fd = open(filename, O_CREAT | O_WRONLY);更换为 
fd = open(filename, O_CREAT | O_WRONLY,0777);

 

网上查了一下,说该错误是由于gcc-4.3对语法检查严格所产生的错误

3.zlib库的解压错误:

如使用tar命令解压zlib包出错且确认该包是完整的,请使用其他的图形化解压软件[甚至可以用windows下的winrar]先解压此包,然后将解压得到的文件夹复制过去再进行编译安装即可.

4.编译autoconf时出现error: GNU M4 1.4 is required: 

出现此错误是由于系统没有安装相关的软件包,打开网址:ftp.gnu.org/gnu/m4/下载用户喜欢的任一版本,用如下的命令进行编译安装即可:

(sudo) ./configure
(sudo) make
(sudo) make install

5.安装gd库时出错 make[2]: *** [gd_png.lo] Error 1:

出错原因:

系统无法找到png.h文件

解决方法:

进入gd库的解压目录编辑gd_png.c文件,找到如下的代码:

#include "png.g"

将之修改为:

#include "/usr/local/libpng/include/libpng12/png.h"

 

注意:修改的文件目录即您安装libpng库时对应文件的目录,此处需要根据您的安装路径酌情修改

6.Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName:


这是一个 warning,出现在apache2启动或重起时。主要是因为在配置 apache2 时,没有指定相应的主机名,即 ServerName。修改/etc/httpd/httpd.conf , 在最前加入 ServerName localhost:80 即可
 

7.配置mysql时出现错误configure: error: No curses/termcap library found: 

说明 curses/termcap 库没有安装

apt-get install libncurses5-dev

 

8.配置mysql自启动时出错:

注释掉/etc/my.cnf里面的--skip-federated

9.mysql无法通过mysqld.sock连接错误的解决方法

 

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

 

 

 chown mysql:mysql /var/run/mysqld

然后重启mysql:/usr/local/mysql/bin/mysql restart

10.apache重启报错

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

 

解决办法:#vim /usr/local/apache2/etc/httpd.conf (在这里/usr/local/apache2是我安装apache的目录,你默认安装的话应该是/usr/local/apache2/)

找到#ServerName www.example.com:80   把#去掉,再重启apache即可没事了。

11.phpize建立php扩展Cannot find config.m4

[root@ns root]# phpize
  Cannot find config.m4.
  Make sure that you run /usr/local/bin/phpize in the top level source directory of the module

解决办法:

在/usr/local/src/php-4.3.5/ext下找到这个工具
  来建立一个php扩展的一个框架
  [root@ns ext]#cd /usr/local/src/php-4.3.5/ext/
  [root@ns ext]# ./ext_skel --extname=sdomain
To use your new extension, you will have to execute the following steps:
  1. $ cd ..
  2. $ vi ext/sdomain/config.m4
  3. $ ./buildconf
  4. $ ./configure --[with|enable]-sdomain
  5. $ make
  6. $ ./php -f ext/sdomain/sdomain.php
  7. $ vi ext/sdomain/sdomain.c
  8. $ make
[root@ns ext]# cd sdomain/
  [root@ns sdomain]# ls
  config.m4 EXPERIMENTAL     sdomain.php  tests
  CREDITS  sdomain.c php_sdomain.h
  然后我们要修改文件顺序是
  configue.m4
  sdomain.c
  php_sdomain.h
使用文本编辑器打开config.m4文件,修改文件内容:
dnl PHP_ARG_WITH(my_module, for my_module support,
  dnl Make sure that the comment is aligned:
  dnl [ --with-my_module       Include my_module support])
修改成
  PHP_ARG_WITH(my_module, for my_module support,
  [ --with-my_module       Include my_module support])
  或者将
dnl PHP_ARG_ENABLE(my_module, whether to enable my_module support,
  dnl Make sure that the comment is aligned:
  dnl [ --enable-my_module      Enable my_module support])
修改成
  PHP_ARG_ENABLE(my_module, whether to enable my_module support,
  [ --enable-my_module      Enable my_module support])
        (其实就是将这部分的dnl去掉,在这个文件里dnl就是注释的意思,相当于我们PHP里面的#或// 另外把他中间的一句描术也去掉)
然后保存退出
  然后在编辑
  Vi my_module.c
  将文件其中的下列代码进行修改
/* Every user visible function must have an entry in my_module_functions[].
*/
function_entry my_module_functions[] = {
    PHP_FE(say_hello,    NULL) /* ?添加着一行代码 */
    PHP_FE(confirm_my_module_compiled,   NULL) /* For testing, remove later. */
    {NULL, NULL, NULL}   /* Must be the last line in my_module_functions[] */
};
  在文件的最后添加下列代码
PHP_FUNCTION(say_hello)
{
    zend_printf("hello sdomain!");
}
 
再修改:php_sdomain.h
vi php_sdomain.h
在PHP_FUNCTION(confirm_my_module_compiled); /* For testing, remove later. */ 这行的下面添加一行:
PHP_FUNCTION(say_hello); /* For testing, remove later. */
  保存文件退出
  然后我们就可以在这个目录下使用上面的命令了
  /usr/local/php/bin/phpize

 

 

posted @ 2013-03-31 19:18  不负韶华668  阅读(285)  评论(0编辑  收藏  举报