编译安装mysql+apache+php _MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2031 | 回复: 0   主题: 编译安装mysql+apache+php         下一篇 
derek
注册用户
等级:中校
经验:1550
发帖:209
精华:0
注册:2011-7-21
状态:离线
发送短消息息给derek 加好友    发送短消息息给derek 发消息
发表于: IP:您无权察看 2014-12-17 11:18:19 | [全部帖] [楼主帖] 楼主

[目录]

   1. 安装Mysql
   2. 安装Apache
   3. 安装PHP
   4. 配置httpd.conf
1. 安装Mysql

 ================


参考文档1:《MySQL Reference Manual》 -> "Installing MySQL on Other Unix-Like Systems"
参考文档2:源代码自带的 INSTALL-SOURCE 文件
1.1 编译安装

 # groupadd mysql
# useradd -g mysql -d /usr/local/lib/mysql -s /sbin/nologin mysql
# tar zxvf mysql-x.x.x
# cd mysql-x.x.x
# ./configure --prefix=/usr/local/lib/mysql --localstatedir=/usr/local/lib/mysql/data --with-charset=utf8 --with-extra-charsets=all
# make
# make install
# cp support-files/my-medium.cnf /etc/my.cnf
# cd /usr/local/lib/mysql
# mkdir data
# bin/mysql_install_db --user=mysql
# chown -R root  .
# chown -R mysql data
# chgrp -R mysql .
# echo "/usr/local/lib/mysql/bin/mysqld_safe &" >> /etc/rc.local
# /usr/local/lib/mysql/bin/mysqld_safe --user=mysql &


1.2 进入mysql的DBMS

 # /usr/local/lib/mysql/bin/mysql -u root -p
enter password:


*注:默认mysql的root用户口令为空
1.3 mysql数据在页面显示为中文乱码的问题

 --with-extra-charsets=all是解决中文乱码的关键参数,它的作用是安装额外的字符集,其中即包括gbk等中文字符集。在创建数据库时手工指定字符集为gbk,这样就可以保证同样使用gbk字符集的HTML页面正常地显示中文了:
create database  default character set gbk collate gbk_chinese_ci;


2. 安装Apache

 ===============


2.1 编译安装

 # tar zxvf httpd-x.x.x.tar.gz
# cd httpd-x.x.x
# ./configure --prefix=/usr/local/lib/apache --enable-so --enable-mods-shared=all --enable-rewrite=shared --enable-speling=shared
# make
# make install


2.2 apache启动停止命令

 # /usr/local/lib/apache/bin/apachectl start
# /usr/local/lib/apache/bin/apachectl stop
# /usr/local/lib/apache/bin/apachectl restart


2.3 自动运行

 # echo "/usr/local/lib/apache/bin/apachectl start" >> /etc/rc.local


2.4 apache启动时可能出现的错误

[Fri Dec 30 09:35:01 2005] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter


解决方法

 ---------
step-1)


编辑/etc/hosts和/etc/rc.conf, 配置主机域名. 例如:

# cat /etc/hosts
127.0.0.1               localhost
192.168.177.130         freebsd6 freebsd6.local
# cat /etc/rc.conf
hostname="freebsd6.local"
...
step-2)
---------
on FreeBSD, you need to add a kernelmodule
kldload accf_http
grep accf /boot/defaults/loader.conf
accf_data_load="NO" # Wait for data accept filter
accf_http_load="NO" # Wait for full HTTP request accept filter
add the second to /boot/loader.conf with 'YES' to enable this permenately.


3. 安装PHP

 ============


步骤:

   3.1 安装libxml2-x.x.x.tar.gz
   3.2 安装libiconv-x.x.x.tar.gz
   3.3 安装gd-x.x.x.tar.gz
   3.4 安装php
3.1 安装libxml2

 # tar zxvf libxml2-x.x.x.tar.gz
# cd libxml2-x.x.x
# ./configure && make && make install
http://xmlsoft.org/


3.2 安装libiconv

 # tar zxvf libiconv-x.x.x.tar.gz
# cd libiconv-x.x.x
# ./configure && make && make install
http://www.gnu.org/software/libiconv/


3.3 安装gd

gd需要以下模块:

. zlib-x.x.x.tar.gz
. libpng-x.x.x.tar.gz


3.3.1 安装zlib

 # tar zxvf zlib-x.x.x.tar.gz
# cd zlib-x.x.x
# ./configure && make && make install


默认情况zlib被安装到/usr/local/include/

 http://directory.fsf.org/zlib.html
http://www.zlib.net/


3.3.2 安装libpng

 # tar zxvf libpng-x.x.x.tar.gz
# cd libpng-x.x.x
# ./configure && make && make install


默认情况libpng被安装到/usr/local/include/libpng/

 http://www.libpng.org/pub/png/libpng.html


3.3.3 安装gd

 # tar zxvf gd-x.x.x.tar.gz
# cd gd-x.x.x
# ./configure && make && make install


默认情况gd被安装到/usr/local/include/

http://www.boutell.com/gd/


*注:我遇到过gd_png.c找不到png库文件的情况, 这时要手工把png.h和pngconf.h两个文件拷贝到gd_png.c所在目录就可以了。
3.4 安装PHP

 # tar zvxf php-x.x.x.tar.gz
# cd php-x.x.x
# ./configure --prefix=/usr/local/lib/php --with-mysql=/usr/local/lib/mysql --with-apxs2=/usr/local/lib/apache/bin/apxs --with-libxml-dir=/usr/local/include/libxml2/libxml --enable-mbstring --with-gd --with-zlib


[编译中遇到点问题(附后1): like

 http://bugs.php.net/bug.php?id=31193
./configure CFLAGS=-liconv --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/include/libxml2/libxml --enable-mbstring --enable-sockets --enable-ftp --with-gd --with-zlib --without-iconv]
# make
# make install
# cp php.ini-dist /usr/local/lib/php/lib/php.ini


3.5 配置php.ini

 # vi /usr/local/lib/php/lib/php.ini
...
default_charset = "gbk"
session.auto_start = 1
max_execution_time = 300  (满足长时间数据计算页面的需要,默认为30)
...


4. 配置httpd.conf

 ====================


4.1 修改ServerName

 ServerName 127.0.0.1:80    (这个选项影响apache的启动)


4.2 支持index.php
找到"DirectoryIndex index.html"
在"index.html"后面加入"index.php"

 DirectoryIndex index.html index.php


4.3 支持php
找到, 在AddType application/x-gzip .gz .tgz下面加入

 AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


4.4 增加目录设置
找到 ... , 在下面加入

 Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all


4.5 增加新的脚本目录
找到 ... , 在下面加入

 AllowOverride None
Options None
Order allow,deny
Allow from all


4.6 增加目录别名(alias)
找到 ... , 在中间区域加入

 Alias /new-doc "/usr/local/lib/apache/htdocs/new-doc"
ScriptAlias /new-cgi "/usr/local/lib/apache/htdocs/new-cgi"
----------------------------------------------------------------
2005/04/09 16:00 - 2005/04/10 13:16 Created by Wandering
2005/12/29 23:28 Modified by Wandering
2006/07/17 23:56 Modified by Wandering


2008/11/22 22:54 Wandering 修改文件名,重修订内容
2008/11/23 19:07 Wandering 增加mysql解决中文乱码方法
本文出自 “Wandering's Blog” 博客,请务必保留此出处http://wandering.blog.51cto.com/467932/114472

 1:
/home/richard/Download/php-5.2.8/ext/gd/libgd/gdkanji.c:350: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/gd/libgd/gdkanji.c:365: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/gd/libgd/gdkanji.c:381: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_appendl':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:348: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:385: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `_php_iconv_mime_decode':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1354: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1465: undefined reference to `libiconv_close'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1468: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1823: undefined reference to `libiconv_close'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1826: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_strlen':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:603: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:626: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:660: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_substr':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:723: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:802: undefined reference to `libiconv_close'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:806: undefined reference to `libiconv_close'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:747: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:755: undefined reference to `libiconv_open'
ext/iconv/.libs/iconv.o: In function `php_iconv_string':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:441: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:453: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:467: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:478: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_strpos':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:851: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:879: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:993: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `_php_iconv_mime_encode':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1043: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1057: undefined reference to `libiconv_open'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1176: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1128: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1160: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1228: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1259: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1316: undefined reference to `libiconv_close'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1319: undefined reference to `libiconv_close'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:1303: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_dtor':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:2465: undefined reference to `libiconv_close'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_append_bucket':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:2615: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:2615: undefined reference to `libiconv'
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:2537: undefined reference to `libiconv'
ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':
/home/richard/Download/php-5.2.8/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1


--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论