免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 11074 | 回复: 8
打印 上一主题 下一主题

[Web] centos5.1最小化安装+apache+php+mysql+gd+zend+phpmyadmin [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-26 19:47 |只看该作者 |倒序浏览
把我这10天的笔记总结到一个文档里,这次centos5.1是采用最小化的安装,全部的软件都是采用编译安装,软件基本都是最新版本。整个编译的过程,我都重复了不下10次。应该是没有问题的,改天我再按照我自己的文档,从新来一次。
我的笔记本只有512m内存,给了vm160m内存,在这种恶劣的情况下完成这个的。

参考了无数的同类文章,cu的web的精华帖几乎都翻遍了。谢谢各位前辈朋友,现在真的很方便了,编译出什么错误,到网上基本都能找到,很难想象,没有搜索,怎么办


1 安装


1.1 CentOS5.1

• 所有需要安装的包都放在/usr/src下,解压也是解压在/usr/src下。
• 所有的软件都是安装在/usr/local下。


1.2 基本信息

• vmware workstation 6.2
• 创建一个redhat as 5.0 vm
• 8g硬盘,160m内存,去掉声卡,软驱
• ip:192.168.1.168
• 掩码:255.255.255.0
• 网关:192.168.1.1
• dns:192.168.1.1
• hostname:centos


1.3 最小化安装

通过命令行的方式进行安装,所有的选择都是采用缺省的,
时区选择:中国
语言:英语
安装了342个包,占用空间是536m,不选择任何组件


1.4 分区

/swap:320
/ :全部空间


2 基本命令使用


2.1 VI

进入编辑状态:i
退出编辑状态:Esc
到第一行:gg
到最後一行:G
到某一行:xxG
到行首:0
到行末:$
复制:yy
贴上:p
复原:u
删整行:dd
删除全部内容:dG
显示行数::set nu
不显示行数::set nonu
搜寻:/、再次搜寻:n
储存::w
离开::q
储存兼离开::wq 或 shift+zz
强制离开(不储存)::q!

2.2 yum

更新:yum update
安装:yum install xxx
移除:yum remove xxx
清除已经安装过的档案(/var/cache/yum/):yum clean all
搜寻:yum search xxx
列出所有档案:yum list
查询档案讯息:yum info xxx

群组安装功能:

yum grouplist
yum groupinstall "Web Server"


2.3 rpm

安装:rpm -ivh xxx
移除:rpm -e xxx
升级:rpm -Uvh xxx

查询:
查询所有安装的包: rpm -qa
查询某个包:rpm -qa | grep xxx
rpm -qi xxx
查询软件的安装路径:rpm -ql xxx
rpm -qc xxx
查询某个文件是那个rpm包产生:rpm -qf /etc/yum.conf
rpm -qpi xxx

2.4 chkconfig

查看所有服务:chkconfig --list
查看3启动的状态:chkconfig --list | grep 3n
把某些服务设置为启动:chkconfig --level 345 xxx on
把某些服务设置当前启动:chkconfig xxx on
列出某项服务:chkconfig --list xxx


2.5 查看系统状态

查看系统使用字符集:echo $LANG $LANGUAGE
环境变量:set


2.6 解压

如果是以gz結尾的如:test.tar.gz
tar zxvf test.tar.gz

如果是以bz或bz2結尾如:test.tar.bz2
tar jxvf test.tar.bz2


2.7 基本信息查看和修改

查看 IP:ifconfig
修改 IP:
运行命令:system-config-network-tui
或修改:/etc/sysconfig/network-scripts/ifcfg-eth0

FQDN 设定:
hostname
more /etc/hosts
more /etc/sysconfig/network
修改计算机名字
1:vi /etc/sysconfig/network
2:vi /etc/hosts
如果通过
hostname xxx
来修改计算机名字,则重新启动后就不起作用

DNS 设定:
vi /etc/resolv.conf
nameserver 192.168.1.1
nameserver 202.106.195.68

重新启动网卡:
/etc/rc.d/init.d/network restart


3 登陆后设置


3.1 关闭selinux

1:运行命令setup,可以在图形化界面进行关闭
2:vi /etc/sysconfig/selinux
SELINUX=enforcing 改成--> SELINUX=disabled


3.2 关闭不需要服务

1:运行命令setup
2:运行命令ntsysv
只启用下面9个服务(autofs是为了方便使用光驱,其实可以不启用这个服务)
acpid
anacron
autofs
cpuspeed
crond
network
sshd
syslog
yum-updatesd

3.3 配置ssh

修改两个地方
vi /etc/ssh/sshd.config
#PermitRootLogin yes 改为
PermitRootLogin yes

#UseDNS yes 改为
UseDNS no


3.4 配置yum


mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.save
vi /etc/yum.repos.d/CentOS-Base.repo

######################

[base]
name=CentOS-5 - Base
repo=os
baseurl=http://centos.ustc.edu.cn/centos/5.1/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[update]
name=CentOS-5 - Updates
baseurl=http://centos.ustc.edu.cn/centos/5.1/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[addons]
name=CentOS-5 - Addons
baseurl=http://centos.ustc.edu.cn/centos/5.1/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[extras]
name=CentOS-5 - Extras
baseurl=http://centos.ustc.edu.cn/centos/5.1/extras/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[centosplus]
name=CentOS-5 - Plus
baseurl=http://centos.ustc.edu.cn/centos/5.1/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[contrib]
name=CentOS-5 - Contrib
baseurl=http://centos.ustc.edu.cn/centos/5.1/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
###################


rpm --import http://centos.ustc.edu.cn/centos/5.1/os/i386/RPM-GPG-KEY-CentOS-5

yum update



4 :编译前准备

4.1 安装编译器gcc
最小化安装,没有安装编译器
yum install gcc

4.2 gcc-c++
如果不安装,在编译mysql的时候会出现【exec: g++: not found】错误
yum install gcc-c++

5:安装软件

5.1安装mysql

1:去下载一个ncurses-5.6.tar.gz,
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install clean


2:安装mysql
tar -zxvf mysql-5.0.51a.tar.gz
cd mysql-5.0.51a
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5 --with-extra-charset=all --without-isam --exec-prefix=/usr/local/mysql5
echo $?
make && make install


3:初始化数据库:
groupadd mysql
useradd -g mysql mysql
scripts/mysql_install_db
cp /usr/local/mysql5/share/mysql/my-medium.cnf /usr/local/mysql5/var/my.cnf
cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
chown mysql:mysql -R /usr/local/mysql5/
service mysqld start
ln -s /usr/local/mysql5/bin/mysql /sbin/mysql
ln -s /usr/local/mysql5/bin/mysqladmin /sbin/mysqladmin


4:设定mysql密码
mysqladmin -uroot password "123456"


5:让系统找到mysql(如果必要的话):
PATH=$PATH:/usr/local/mysql5/bin
export PATH
echo "/usr/local/mysql5/lib/mysql" >> /etc/ld.so.conf
ldconfig

6::测试
netstat -nplt | grep mysql
ps aux|grep mysql

5.2 安装apache

1:编译安装
tar zxvf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
echo $?
make && make install
/usr/local/apache2/bin/apachectl configtest
/usr/local/apache2/bin/apachectl start
/usr/local/apache/bin/apachectl stop
2:修改默认启动页
vi /usr/local/apache2/conf/httpd.conf
DirectoryIndex index.html 改为
DirectoryIndex index.html index.htm default.htm default.html index.php index.php3 index.jsp
#ServerName www.example.com:80 改为
ServerName www.example.com:80

3:apache 开机启动的办法
1:#echo "/usr/local/apache/bin/apachectl start" >>/etc/rc.local(系统启动时服务自动启动)
2:创建一个httpd启动脚本,内容如下:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd
在第三行添加以下内容
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.

chmod +x /etc/rc.d/init.d/httpd
chkconfig --add httpd

修改乱码
步骤1:   
在httpd.conf中将Include conf/extra/httpd-autoindex这个模块的注释去掉
@vi /usr/local/apache/conf/httpd.conf
步骤2:   
在httpd-autoindex.conf中加入IndexOptions Charset=UTF-8
@vi /usr/local/apache/conf/extra/httpd-autoindex.conf

5.3 安装GD

1:安装ZLIB2

######zlib#############

tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install clean

2:安装PNG

##########libpng###########

tar zxvf libpng-1.2.26.tar.gz
cd libpng-1.2.26

cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng

make
make install clean

3:安装freetype

##########freetype#########

cd freetype-2.3.5
./configure
make
make install

4:安装JPEG6


#########jpeg###############

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
./configure --prefix=/usr/local/jpeg --enable-shared --enable- static
make
make install

5:安装GD
########GD###########

tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --with-png --with-freetype --with-jpeg=/usr/local/jpeg/

make
make install

5.4 安装php

1:安装LIBXML2
#####libxml2 #####

tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
make
make install
cp xml2-config /usr/bin

2::安装PHP5.2.5

#########php##########

tar zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=usr/local/libpng12 --with-libxml-dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets
make
make test

make install


3:配置
cp php.ini-dict /usr/local/php5/lib/php.ini
编辑httpd.conf
/usr/local/apache2/conf/httpd.conf
加载php模块,去掉注释,我的版本是缺省就启用的。
LoadModule php5_module        modules/libphp5.so

加上下面两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps


5.5 安装zend

tar -zxvf ZendOptimizer-3.0.0-linux-glibc23- x86_64.tar.gz
cd ZendOptimizer-3.0.0-linux-glibc23-x86_64
./install

5.6 安装phpmyadmin

cp -rf phpMyAdmin-v2.11.5.2 /usr/local/apache2/htdocs/phpmyadmin

cd /usr/local/apache2/htdocs/phpmyadmin/

cp config.sample.inc.php config.inc.php
vi config.inc.php
$cfg['blowfish_secret'] = ''改为
$cfg['blowfish_secret'] = 'dd'

只要不为空就可以了,这样就可以登陆,如果还有问题,就修改一下语言就解决“配置文件现在需要绝密的短语密码(blowfish_secret)”这个错误了。













6:软件

ncurses

http://ftp.gnu.org/pub/gnu/ncurses/ncurses- 5.6.tar.gz

安装GD库和GD库所需的环境
zlib
http://www.zlib.net/zlib-1.2.3.tar.gz
jpeg
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
freetype
http://download.savannah.gnu.org/releases/freetype/freetype- 2.3.5.tar.gz
png
ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng- 1.2.26.tar.gz
GD
http://www.libgd.org/releases/gd-2.0.35.tar.gz

安装php必须安装libxml
wget ftp://xmlsoft.org/libxml2/libxml2-2.6.31.tar.gz

apache2.2.8
http://apache.mirror.phpchina.com/httpd/httpd- 2.2.8.tar.gz
phpmyadmin2.11.5.2
http://4.gxdx1.crsky.com/200804/phpMyAdmin- v2.11.5.2.rar

Zend3.3
http://downloads.zend.com/optimi ... glibc21-i386.tar.gz

php5.2.5
http://cn.php.net/distributions/php- 5.2.5.tar.gz
mysql5.051
http://mirror.trouble- free.net/mysql_mirror/Downloads/MySQL- 5.0/mysql-5.0.51a.tar.gz

[ 本帖最后由 eddiechen 于 2008-4-27 01:12 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-04-28 10:09 |只看该作者
没什么好说的,楼主的精神值得学习

不过,vmware workstation好像最新的才6.0.3吧。。。。

[ 本帖最后由 ubuntu590 于 2008-4-28 10:14 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2008-04-28 10:54 |只看该作者
搞错啊,我用的是6.02,佩服,看的那么仔细

论坛徽章:
0
4 [报告]
发表于 2008-04-28 10:57 |只看该作者

phpmyadmin下的两个错误的解决办法

当你配置好,登陆phpmyadmin,你会发现有两个错误

1:没有mbstring 扩展的phpMyAdmin 不能正确识别字符串,可能产生不可意料的结果

2:无法载入 mcrypt 扩展,<br />请检查 PHP 配置

网上搜索了一下,基本找到的都是windows下使用的解决办法,我这里是linux,怎么搞定。

第一问题,比较好办,只需要编译php的时候加入参数-enable-mbstring=all 就可以了。

第二个问题就比较麻烦,这应该是出现在新的版本的phpmyadmin里,不过搜索找到了答案。

到这里ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/下载libmcrypt-2.5.7.tar.gz,编译很简单,依旧是configure,make,make check,make install。

装完马上重新去编译php,安装非常顺利。

我已经测试通过了,非常不错。大家可以去看看作者的blog,久闻大名。

现在已经是深夜2点了,明天还有参加朋友的婚礼。

下面是我的编译参数,记录一下

./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/include/freetype2 --with-zlib --with-png-dir=usr/local/libpng12 --with-libxml-dir=/usr/local/libxml2 --with-gd --enable-ftp --enable-sockets -enable-mbstring=all- --with-mcrypt


http://blog.5ilinux.com/archives/linux/


http://www.weithenn.idv.tw/cgi-b ... E%A7%E5%88%B6_Mysql

http://itblog.blogdns.net/index.php?load=read&id=27

http://www.centos.org/modules/newbb/viewtopic.php?topic_id=6516

论坛徽章:
0
5 [报告]
发表于 2010-05-20 19:29 |只看该作者
顶起,认真研究一下

论坛徽章:
0
6 [报告]
发表于 2010-05-21 09:24 |只看该作者
我觉得这样的东西,最好是做成一个大的rpm包,

然后只需要装一个rpm,就可以搞定一切。

论坛徽章:
0
7 [报告]
发表于 2010-05-21 20:06 |只看该作者
顶起,认真研究一下

论坛徽章:
0
8 [报告]
发表于 2010-06-08 11:19 |只看该作者
欢迎写成安装角本。 

论坛徽章:
0
9 [报告]
发表于 2010-06-09 09:56 |只看该作者
不错!
还是喜欢编译安装,看的中规中矩!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP