Suse Linux下安装配置Apache+php+mysql

Suse Linux下安装配置Apache+php+mysql

 

 

 
本文介绍suse linux下简单WEB环境的配置方法:

安装软件。
一、准备软件包
存放/home/xiutuo/software/目录下。
主要软件包,(这里没有选择mysql-standard-5.0.20-linux-i686.tar.gz,呆会再说明原因。)
httpd-2.2.0.tar.gz
mysql-max-5.0.21-linux-i686-glibc23.tar.gz
php-5.1.2.tar.gz
安装php所需的软件包
(其中libxml2是安装php5必须的,为什么还需要perl呆会说明原因。)
libxml2-2.6.19.tar.gz 
libxslt-1.1.15.tar.gz
ActivePerl-5.8.8.817-i686-linux-2.2.17-gcc-257965.rpm
curl-7.15.0.tar.gz
GD库所需要软件包(有人说PHP源码包里自带了GD2.0.28和zlib,只要安装GD的三个支持包:jpg,png和freetype,但是我们还是下载
gd-2.0.33.tar.gz
freetype-2.1.10.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.8.tar.gz
zlib-1.2.3.tar.gz
相关下载(根据自己的linux版本下载相应的包,查看操作系统版本:# uname -r )
http://ftp.gnome.org/pub/GNOME/sour...2-2.6.19.tar.gz
http://ftp.gnome.org/pub/GNOME/sour...t-1.1.15.tar.gz
http://downloads.activestate.com/Ac...-i686-linux.rpm
http://curl.haxx.se/download/curl-7.15.0.tar.gz
http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
http://keihanna.dl.sourceforge.net/...e-2.1.10.tar.gz
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
http://nchc.dl.sourceforge.net/sour...ng-1.2.8.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.gz 
把以上所有软件包下载到:/home/xiutuo/software/目录下。
二、安装apache2。
# cd /home/xiutuo/software/ 
进入目录/home/xiutuo/software/
# tar -zvxf httpd-2.2.0.tar.gz
解压httpd-2.2.0.tar.gz
# cd httpd-2.2.0
进入httpd-2.2.0目录
# mkdir -p /usr/local/apache2
生成/usr/local/apache2目录
# ./configure --prefix=/usr/local/apache 
或者
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
# make; make install
安装apache
# vi /usr/local/apache/conf/httpd.conf
#ServerName www.example.com:80 在其下增加
ServerName www.xiutuo.com:80
保存退出,现在就这么简单配置apache。
# /usr/local/apache/bin/apachectl -k start 
启动apahce,
用浏览器查看http://www.xiutuo.com,得到it works,说明apache已经配置成功了。
# /usr/local/apache/bin/apachectl -k stop
停止apache。
三、安装mysql
# cd /home/xiutuo/software/ 
# tar -zvxf mysql-max-5.0.21-linux-i686-glibc23.tar.gz
# mkdir -p /usr/local/mysql (省略也可)
# cp -r mysql-max-5.0.21-linux-i686-glibc23.tar.gz /usr/local/mysql
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
添加mysql用户及用户组
# groupadd mysql
# useradd -g mysql mysql
修改mysql目录权限
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/data
生成mysql系统数据库
#/cp /usr/local/mysql/scripts/mysql_install_db ../
# /usr/local/mysql/mysql_install_db --user=mysql&
启动mysql服务
# /usr/local/mysql/bin/mysqld_safe --user=mysql&
如出现 Starting mysqld daemon with databases from /usr/local/mysql/data
代表正常启动mysql服务了, 按Ctrl + C 跳出
修改 mysql 的 root 密码
# /usr/local/mysql/bin/mysqladmin -u root -p password "123456"
如果在安装的过程中,mysql不是被安装在/usr/local/mysql,注意调整../mysql/bin/mysqld_safe这个文件中的路径。 
四、安装GD库(让PHP支持GIF,PNG,JPEG)
a.安装 jpeg6
建立目录:
# mkdir -p /usr/local/jpeg6 
# mkdir -p /usr/local/jpeg6/bin 
# mkdir -p /usr/local/jpeg6/lib 
# mkdir -p /usr/local/jpeg6/include 
# mkdir -p /usr/local/jpeg6/man 
# mkdir -p /usr/local/jpeg6/man1
# mkdir -p /usr/local/jpeg6/man/man1
# cd /home/xiutuo/software/ 
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
# make; make install
b.安装libpng
# cd /home/xiutuo/software/ 
# tar -zvxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile 
# make; make install 
c.安装 freetype
# cd /home/xiutuo/software/ 
# tar -zvxf freetype-2.1.10.tar.gz 
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype 
# make;make install
d.:安装zlib
# cd /home/xiutuo/software/ 
#tar -zxvf zlib-1.2.3.tar.gz
#cd zlib.1.2.3
# ./configure
# make;make install
e.安装GD库
# cd /home/xiutuo/software/ 
# tar -zvxf gd-2.0.33.tar.gz 
# mkdir -p /usr/local/gd2
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/ --with-zlib=/usr/local/lib/ --with-freetype=/usr/local/freetype/
# make; make install
e.安装Curl库
# cd /home/xiutuo/software/ 
# tar -zxf curl-7.15.0.tar.gz
# mkdir -p /usr/local/curl
# ./configure --prefix=/usr/local/curl
# make; make install
五、安装php5,php5必须有libxml2支持!
a.安装libxml2
# cd /home/xiutuo/software/
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make; make install
b.安装 libxslt(可选安装,你可以不安装
# cd /home/xiutuo/software/
# tar -zxf libxslt-1.1.15.tar.gz
# mkdir -p /usr/local/libxslt
# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make; make install
c.安装php5
# cd /home/xiutuo/software/
# tar -zvxf php-5.1.2.tar.gz 
# mkdir -p /usr/local/php
# cd php-5.05
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/ 
--with-curl=/usr/local/curl --enable-ftp 
--with-libxml-dir=/usr/local/libxml2 
--with-expat-dir=/usr/lib --enable-soap 
--with-xsl=/usr/local/libxslt --enable-xslt 
--with-gd=/usr/local/gd2/ 
--with-jpeg-dir=/usr/local/jpeg6/ 
--with-zlib-dir=/usr/local/lib/
--with-png=/usr/local/lib/
--with-freetype-dir=/usr/local/freetype/ 
//…编译程序时提示下面的信息解决方法: configure: error: cannot find output from lex; giving up 方法很简单,在编译语句之前执行命令: touch lex.yy.c 这样就 OK 了…//
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini (别忘记了呵呵)
其中./configure 后的 
--prefix=/usr/local/php 
--with-apxs2=/usr/local/apache/bin/apxs 
--with-mysql=/usr/local/mysql/
--with-libxml-dir=/usr/local/libxml2
是必要的选项
--with-gd=/usr/local/gd2/ 
--with-jpeg-dir=/usr/local/jpeg6/ 
--with-png=/usr/local/lib 
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
这是让PHP支持GD库的配置选项
--with-curl=/usr/local/curl 支持CURL库
--enable-ftp 打开FTP库函数支持
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
PHP支持SOAP, 上面这些一般用得少, 可以去掉
 
六、重新配置apache2让他支持php。
配置 httpd.conf 让apache支持PHP
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
重启apache
# /usr/local/apache/bin/apachectl restart
在htdocs目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确

安装中出现的问题
1、当你看到mysql有很多版本,如:
mysql-max-5.0.21-linux-i686-glibc23.tar.gz和
mysql-max-5.0.21-linux-i686.tar.gz
这俩个到底选哪个呢,请你使用如下命令来决定
# rpm -qa | grep glibc
glibc-kernheaders-2.4-8.10
glibc-common-2.3.2-11.9
glibc-2.3.2-11.9
glibc-devel-2.3.2-11.9
如果出现以上信息,请选择mysql-max-5.0.21-linux-i686-glibc23.tar.gz版本
2、编译php时出现
./configure: /usr/local/apache2/bin/apxs: 
/replace/with/path/to/perl/interpreter:
bad interpreter: No such file or directory
这是找不到perl解释器的缘故。
修改/usr/local/apache2/bin/apxs文件中:
/replace/with/path/to/perl/interpreter
把他替换成perl所在的路径如/opt/ActivePerl-5.8/bin/perl,
(如果你下载的是active perl5.8的rpm,他默认安装路径是/opt/ActivePerl-5.8/bin/perl)
3、安装perl后,发现所有的文本编辑器都不能用了。
运行vi或者gedit时候,提示找不到libperl.so
perl安装目录下找一个libperl.so放到/usr/lib目录下就解决问题了
我的libperl.so在/opt/ActivePerl-5.8/lib/5.8.8/i686-linux-thread-multi-CORE/目录下。
如果不知道libperl.so在什么地方,可以用
# locate libperl.so
查找,或者用find命令
4、当我使用mysql-standard-5.0.20,编译php时出现mysql错误:
checking for mSQL support... no
checking for MSSQL support via FreeTDS... no
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... /tmp/mysql.sock
checking for mysql_close in -lmysqlclient... no
checking for mysql_error in -lmysqlclient... no
configure: error: mysql configure failed. Please check config.log 
for more information.
网查找说:安装PHP的时候没有指定一下mysql的安装目录。但是我已经指定了,所以这个说法是错误的,其实主要原因是 mysql-level没有装,也就是mysql的版本不对,应该换mysql-max-5.0.21版本(包含所有mysql相关内容的软件包)
5、编译php时出现
configure: error: freetype2 not found! 
没有安装freetype-level
configure: error: libpng.(a|so) not found. 
没有安装libpng-devel
6、忘了mysql的root口令怎么办
# /usr/local/mysql/support-files/mysql.server stop
# mysqld_safe --skip-grant-tables & 
# mysqladmin -u user password 'newpassword'
# mysqladmin flush-privileges

posted @ 2014-05-13 11:16  huidaoli  阅读(1379)  评论(0编辑  收藏  举报