首页  >  文章  >  数据库  >  MySQL+PHP5+Apache安装手记(Linux版本)

MySQL+PHP5+Apache安装手记(Linux版本)

WBOY
WBOY原创
2016-06-07 16:14:071055浏览

以下的文章主要介绍的是在linux操作系统之下对Mysql+php5+apache安装手记的具体描述,我前两天在相关网站看见Mysql+php5+apache安装手记的资料,觉得挺好,于是就拿出来供大家分享。 下载官方推荐的稳定版本httpd-2.2.3.tar.gz, 安装apache2 #./configure p

以下的文章主要介绍的是在linux操作系统之下对Mysql+php5+apache安装手记的具体描述,我前两天在相关网站看见Mysql+php5+apache安装手记的资料,觉得挺好,于是就拿出来供大家分享。

下载官方推荐的稳定版本httpd-2.2.3.tar.gz,

安装apache2

<ol class="dp-xml">
<li class="alt"><span><span>#./configure –</span><span class="attribute">prefix</span><span>=/usr/local/apache2 –</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">alias</span><span> –</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">most</span><span> \  </span></span></li>
<li>
<span>–</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">vhost_alias</span><span> –</span><span class="attribute">enable-shared</span><span>=</span><span class="attribute-value">vhost_alias</span><span> –</span><span class="attribute">enable-module</span><span>=</span><span class="attribute-value">so</span><span> –</span><span class="attribute">enable-shared</span><span>=</span><span class="attribute-value">max</span><span> </span>
</li>
<li class="alt"><span># make;make install </span></li>
</ol>

下载目前最新稳定版本mysql-standard-5.0.27-linux-i686-glibc23.tar.gz

无需安装,解压后移至/usr/local/mysql.

# groupadd mysql #建立mysql组

# useradd mysql -g mysql #建立mysql用户并且加入到mysql组中

# cd /usr/local/mysql

然后设置权限

<ol class="dp-xml">
<li class="alt"><span><span># chown -R root . #设定root能访问/usr/local/mysql  </span></span></li>
<li><span># chown -R mysql data #设定mysql用户能访问/usr/local/mysql/data ,里面存的是mysql的数据库文件  </span></li>
<li class="alt"><span># chown -R mysql data/. #设定mysql用户能访问/usr/local/mysql/data下的所有文件  </span></li>
<li><span># chown -R mysql data/mysql/. #设定mysql用户能访问/usr/local/mysql/data/mysql下的所有文件  </span></li>
<li class="alt"><span># chgrp -R mysql . #设定mysql组能够访问/usr/local/mysql </span></li>
</ol>

运行mysql:

<ol class="dp-xml"><li class="alt"><span><span># /usr/local/mysql/bin/mysqld_safe –</span><span class="attribute">user</span><span>=</span><span class="attribute-value">mysql</span><span> & </span></span></li></ol>

修改root密码,默认为空:

<ol class="dp-xml"><li class="alt"><span><span>/usr/local/mysql/bin/mysqladmin -u root password ‘newpassword’ </span></span></li></ol>

MYSQL+php5+apache安装完成

下载最新稳定版本php-5.1.6.tar.gz,

1. 安装zlib (安装libpng和gd前需要先安装zlib),

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf zlib-1.2.3.tar.gz  </span></span></li>
<li><span># cd zlib-1.2.3  </span></li>
<li class="alt"><span># ./configure  </span></li>
<li><span># make;make install </span></li>
</ol>

2. 安装libpng,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf libpng-1.2.12.tar.gz  </span></span></li>
<li><span># cd libpng-1.2.12  </span></li>
<li class="alt"><span># ./configure  </span></li>
<li><span># make;make install </span></li>
</ol>

3. 安装freetype,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf freetype-2.2.1.tar.gz  </span></span></li>
<li><span># cd freetype-2.1.10  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/freetype  </span>
</li>
<li><span># make;make install </span></li>
</ol>

4. 安装jpeg,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf jpegsrc.v6b.tar.gz  </span></span></li>
<li><span># cd jpeg-6b  </span></li>
<li class="alt"><span># mkdir /usr/local/jpeg  </span></li>
<li><span># mkdir /usr/local/jpeg/bin  </span></li>
<li class="alt"><span># mkdir /usr/local/jpeg/lib  </span></li>
<li><span># mkdir /usr/local/jpeg/include  </span></li>
<li class="alt"><span># mkdir /usr/local/jpeg/man  </span></li>
<li><span># mkdir /usr/local/jpeg/man/man1  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/jpeg –enable-shared –enable-static  </span>
</li>
<li><span># make;make install </span></li>
</ol>

5. 安装gd,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf gd-2.0.33.tar.gz  </span></span></li>
<li><span># cd gd-2.0.33  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/gd –</span><span class="attribute">with-jpeg</span><span>=/usr/local/jpeg –</span><span class="attribute">with-freetype</span><span>=/usr/local/freetype –with-png –with-zlib </span>
</li>
</ol>

Mysql+php5+apache编译过程中会看到如下信息

** Configuration summary for gd 2.0.33:

<ol class="dp-xml">
<li class="alt"><span><span>Support for PNG library: yes  </span></span></li>
<li><span>Support for JPEG library: yes  </span></li>
<li class="alt"><span>Support for Freetype 2.x library: yes  </span></li>
<li><span>Support for Fontconfig library: no  </span></li>
<li class="alt"><span>Support for Xpm library: no  </span></li>
<li><span>Support for pthreads: yes </span></li>
</ol>

可以看到png 、 jpeg 、 freetype都已经安装上了

<ol class="dp-xml">
<li class="alt"><span><span># make  </span></span></li>
<li><span># make install  </span></li>
</ol>

6. 正式安装php

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf php-5.1.6.tar.gz  </span></span></li>
<li><span># cd php-5.1.6  </span></li>
<li class="alt">
<span># ./configure –</span><span class="attribute">prefix</span><span>=/usr/local/php5 –</span><span class="attribute">with-apxs2</span><span>=/usr/local/apache2/bin/apxs –</span><span class="attribute">with-mysql</span><span>=<br>/usr/local/mysql –with-gd –with-zlib –with-png –with-jpeg –with-freetype <br>–enable-sockets –with-iconv –enable-mbstring –enable-track-vars –enable-force-cgi-redirect –</span><span class="attribute">with-config-file-path</span><span>=/usr/local/php5/etc </span>
</li>
</ol>

7.整合php和apache

<ol class="dp-xml">
<li class="alt"><span><span>cp php.ini-dist /usr/local/php5/etc/php.ini  </span></span></li>
<li><span>vi /usr/local/php5/etc/php.ini </span></li>
</ol>

将extension=php_mysql.dll前面的#去掉

8. 安装ZendOptimizer,

<ol class="dp-xml">
<li class="alt"><span><span># tar zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz  </span></span></li>
<li><span># cd ZendOptimizer-3.0.1-linux-glibc21-i386  </span></li>
<li class="alt"><span># ./install.sh </span></li>
</ol>

安装操作: [ok] -> [EXIT] -> [YES] -> [/httpd/zend] -> [/httpd/apache/conf] -> [yes] -> [OK] -> [OK] -> [NO]

遇到的一些错误解决:

1.php5在configure时提示:configure: error: mysql configure failed.,只用–with-mysql参数提示:Cannot find MySQL header files under yes,去掉–with-mysql参数可以安装,php5将无法连接mysql+php5+apache,页面提示为:Fatal error: Call to undefined function mysql_connect()。

查阅了一下,发现是mysql5对应的版本不对导致的,换个版本就可以了。
我用mysql-standard-5.0.27-linux-i686.tar.gz时会提示,换了mysql-standard-5.0.27-linux-i686-glibc23.tar.gz后就正常了。

2.重装mysql后启动出错,提示:

<ol class="dp-xml">
<li class="alt"><span><span>Starting mysqld daemon with databases from /usr/local/mysql/data  </span></span></li>
<li><span>STOPPING server from pid file /usr/local/mysql/data/xmcncn.pid  </span></li>
<li class="alt"><span>061103 15:25:32 mysqld ended </span></li>
</ol>

请教高手gump,解决方法:

<ol class="dp-xml">
<li class="alt"><span><span>touch /tmp/mysql.sock  </span></span></li>
<li><span>killall -9 mysqld  </span></li>
<li class="alt">
<span>/usr/local/mysql/bin/mysqld_safe </span><span class="attribute">-user</span><span>=</span><span class="attribute-value">mysql</span><span> & </span>
</li>
</ol>

成功启动

PS:偶是新手,当初找齐这些软件都化了一整天时间,特别是几个小软件比较难找,现在全部列出来了。测试装的时候也遇到了不少问题,在gump同志的帮助下解决了不少。我站上本来转载了好几篇安装的文章,有的版本较旧,有的不太全面,所以把这次安装过程写出来,以后安装也就方便了:)希望也对一些新手有帮助。


 


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn