Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1436891
  • 博文数量: 463
  • 博客积分: 10540
  • 博客等级: 上将
  • 技术积分: 5450
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-12 08:30
文章分类

全部博文(463)

文章存档

2014年(2)

2012年(14)

2011年(42)

2010年(18)

2009年(78)

2008年(35)

2007年(182)

2006年(92)

我的朋友

分类: LINUX

2008-05-13 11:13:07

lamp安装centos+apache+mysql+php+gd2+phpmyadmin集成安装
 
 
 
Redhat Linux 下 PHP5 + MySQL5 + GD2 + Proftpd + phpmyadmin 简易安装配置
一直想写篇关于Linux下 PHP环境的详细安装配置文章, 没什么时间
趁现要配几台服务器, 借此机会把自己安装配置的步骤写出来, 供初学者参考!
先找到 apache php mysql proftpd 源码包下载的URL地址
请浏览




等官方网站
第一步:安装apache
注:当前目录为/tmp,
目录下有httpd-2.2.4.tar.gz, php-5.2.3.tar.gz等二进制源码包
#号代表为root 根权限,#后是输入的一条命令
执行下列命令
解压源码包
# tar -zxf httpd-2.2.4.tar.gz
进入安装目录
# cd httpd-2.2.4
配置apache安装信息
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
执行make安装
# make; make install
安装完后
# vi /usr/local/apache/conf/httpd.conf
找到 prefork.c 下的
MaxClients 150
改为
ServerLimit 2000
MaxClients 1000
apache默认工作在prefork.c模式下,并发进程为150,超过后就无法访问,150是远远不够的,所以这里按自己网站的需求改, 如1000
由于apache默认最大并发进程是 256 所以要先设置 ServerLimit 2000 将服务器可设的最大并发数设为2000, 然后再设置最大并发数 MaxClients 1000
找到 #ServerName 在其下设置 ServerName 如下
ServerName
基中 为你网站名,也可用IP代替
找到 DocumentRoot "/usr/local/apache/htdocs"
设置你的 WEB 服务器的根目录 如
DocumentRoot "/myweb"
找到 DirectoryIndex index.html index.html.var 改为
DirectoryIndex index.html index.php index.htm
找到 ForceLanguagePriority Prefer Fallback 在其下加上
AddDefaultCharset gb2312
改完后保存(vi 的用法请查 Linux vi 命令)
用下面命令启动WEB服务器
# /usr/local/apache/bin/apachectl start
查看自己的站点是否正常 也可用IP
用 # /usr/local/apache/bin/apachectl stop 可停止服务

安装MYSQL二进制文件包,解压即可使用
# tar -zxf mysql-standard-5.2.10-linux-i686.tar.gz
# cp -r mysql-standard-5.2.10-linux-i686 /usr/local/mysql
# vi /usr/local/mysql/support-files/my-medium.cnf
在后面加上
max_connections = 1000
log-slow-queries
long_query_time = 5
注 max_connections 为允许的最大连接数
log-slow-queries 打开低速查询日志
long_query_time 低速查询的秒数(运行一句sql达到此时间记录在日志里)
然后COPY 它为 /etc/my.cnf 文件
# 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系统数据库
# /usr/local/mysql/scrīpts/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
回车出现 Enter password: 最开始密码默认为空 继续回车即可
123456 即为你的新密码
注意:在安装MySQL5.0的时候会出现一个问题,就是和PHP联合编译的时候提示-lmysqlclient错误,这个原因是因为使用了另外一个版本的MySQL,我们需要使用的是Linux x86那个版本,不要是glibc-2.2那个。参考()
 
安装GD库(让PHP支持GIF,PNG,JPEG)
首先下载 jpeg6,libpng,freetype 并安装模块
wget
wget
wget
wget
安装 jpeg6
建立目录
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# cd /tmp
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make; make install
安装libpng
# cd /tmp
# tar -zxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scrīpts/makefile.std makefile
# make; make install
安装 freetype
# cd /root/soft
# tar -zxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# ./configure --prefix=/usr/local/freetype
# make;make install
安装最新的GD库
# cd /tmp
# tar -zxf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
# make; make install
安装PHP
由于php5需libxml2的支持, 所以先下载并安装libxml2
# cd /tmp
# wget
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# ./configure --prefix=/usr/local/libxml2
# make; make install
安装 libxslt
# cd /tmp
# wget
# tar -zxf libxslt-1.1.15.tar.gz
# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make; make install
# tar -zxf php-5.2.3.tar.gz
# cd php-5.2.3
# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-mbstring
# make
# make install
其中./configure 后的
--prefix=/usr/local/php5
--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
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
这是让PHP支持GD库的配置选项
配置 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
在这里有一个问题,如果你的系统安装了SELinux模块,那么由于安全控制的原因,会出现如下错误:
Starting httpd: Syntax error on line 191 of /etc/httpd/conf/httpd.conf:
Cannot load /etc/httpd/modules/libphp5.so into server: libxml2.so.2: failed to map segment from shared object: Permission denied
                                                           [FAILED]
这样需要我们到指定的库文件的目录下执行如下命令:
restorecon libxml2.so.2.6.19
把类似的错误都解决之后,Apache就可以正常启动了。
 
在你Web目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确

安装 phpmyadmin
下载
# cd /tmp
# wget
# tar -zxf phpMyAdmin-2.10.1.tar.gz
phpMyAdmin必须需要PHP支持MySQL。
并且在2.8以后的版本,解压完毕后,首先需要手工建一个config目录,然后配置完毕后,需要点击页面上的Configuration中的Save把文件存成config.inc.php。
# vi phpMyAdmin-2.10.1/config.inc.php
找到 $cfg['Servers'][$i]['auth_type'] = 'config'; 将config 改为 http
保存后
mv phpMyAdmin-2.10.1 /你的phpmyadmin目录
进入phpmyadmin管理
注: PHP连接mysql4.1和5.0 数据库后需指定字符集 需执行如 mysql_query("SET NAMES 'gb2312' ");
否则会产生中文乱码问题!
 
 
阅读(1386) | 评论(0) | 转发(0) |
0

上一篇:清空iptables规则

下一篇:LAMP 安装

给主人留下些什么吧!~~