找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 服务器 Linux/BSD 查看内容

centosLamp环境配置文档V1.2

2009-12-20 13:27| 发布者: admin| 查看: 38| 评论: 0|原作者: 仙之剑缘


PM包和源码包存放位置 /root
MySQL 数据库位置 /opt/mysql
Apache 网站根目录 /opt/www
1. 使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)
yum -y install gcc gcc-c gcc-g77 flex bison autoconf automake libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libxml2 libxml2-devel libtiff libtiff-devel pam pam-devel
这里我们将编译GD所必须的一些小软件比如libpng,libtiff,freetype,libjpeg等先用RPM的方式一并安装好,避免手动编译浪费时间,同时也能避免很多错误,这几个小软件的编译很麻烦。这几个小软件编译错误了,GD当然安装不了,php5的编译当然也没戏了。所以我们抓大放小,对这些小牛鬼蛇神采取快速简洁的方式进行安装。并且对服务器的性能也不能产生什么影响。
2.下载并解压mysql php apache源码程序
[root@localhost ~]#wget
http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz
[root@localhost~]#wget
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.26-rc.tar.gz/from/http://mirror.x10.com/mirror/mysql/
[root@localhost ~]#wget
http://cn.php.net/distributions/php-5.2.6.tar.gz
[root@localhost~]#wget
http://nchc.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.9.1-all-languages.tar.gz
wget
http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
[root@localhost ~]#tar zxvf mysql*
[root@localhost ~]#tar zxvf php*
[root@localhost ~]#tar zxvf httpd*
安装mysql
[root@localhost ~]# cd mysql*
[root@localhost mysql-5.1.26-rc]# ls //查看解压的文件
[root@localhost mysql-5.1.26-rc]#vi INSTALL-SOURCE //查看安装详细步骤
增加MySQL组和 MySQL用
[root@localhost mysql-5.1.26-rc]# groupadd mysql
[root@localhost mysql-5.1.26-rc]#useradd -g mysql mysql
配置发布版并且编译:
[root@localhost mysql-5.1.26-rc]#./configure --prefix=/opt/mysql
configure的相关参数:
--prefix=/home/mysql/ \指定安装目录
--without-debug \去除debug模式
--with-extra-charsets=gbk,gb2312,utf8 \添加gbk,gb2312,utf8中文字符支持
--with-pthread \强制使用pthread库(posix线程库)
--enable-assembler \使用一些字符函数的汇编版本
--enable-thread-safe-client \以线程方式编译客户端
--with-client-ldflags=-all-static \以纯静态方式编译客户端
--with-mysqld-ldflags=-all-static\以纯静态方式编译服务端
--without-isam \去掉isam表类型支持,现在很少用了,isam表是一种依赖平台的表
--without-innodb\去掉innodb表支持,innodb是一种支持事务处理的表,适合企业级应
[root@localhost mysql-5.1.26-rc]#make
[root@localhost mysql-5.1.26-rc]#make install
如果你想要设置一个选项文件,使用support-files目录中的一个作为模板
[root@localhost mysql-5.1.26-rc]# cp support-files/my-medium.cnf /etc/my.cnf
进入安装目录
[root@localhost mysql-5.1.26-rc]#cd /opt/mysql
如果还没有安装的MySQL,必须创建MySQL授权表
[root@localhost mysql]#bin/mysql_install_db --user=mysql
将程序二进制的所有权改为root,数据目录的所有权改为你运行mysqld的用户
[root@localhost mysql]# chown -R root . //注意后面有一空格后一点
[root@localhost mysql]# chown –R mysql var
[root@localhost mysql]#chgrp -R mysql . //注意后面有一空格后一点
《第一个命令将文件的所有属性改为root用户。第二个命令将数据目录的所有属性改为mysql用户。第三个命令将组属性改为mysql组》
[root@localhost ~]#/opt/mysql/bin/mysqld_safe --user=mysql &
[2] 20152
[1] Exit 127 bin/mysql_safe --user=mysql
[root@localhost mysql5]# Starting mysqld daemon with databases from /opt/mysql5/var

以下命令用于设置mysql开机自动运行
[root@localhost mysql]#cd
[root@localhost ~]# cd mysql*//再次进入解压后的目录,即源码目录。
[root@localhost mysql-5.1.26-rc]#cp support-files/mysql.server /etc/init.d/mysql
将mysql.server这个文件copy到/etc/init.d/目录下,并更名为mysql
[root@localhost mysql-5.1.26-rc]#chmod 755 /etc/init.d/mysql //-rw-r--r-- 1 root root 12051 Sep 17 11:49 mysql -----》-rwxr-xr-x 1 root root 12051 Sep 17 11:49 mysql
给/etc/init.d/mysql这个文件赋予“执行”权限
[root@localhost mysql-5.1.26-rc]#chkconfig --level 345 mysql on
加入到开机自动运行,运行级别为3 4 5
[root@localhost ~]#init 6 重新启动
[root@localhost mysql5]#ps -ef | grep mysql 查看mysql 进程
root 20152 3999 0 16:30 pts/0 00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql 20176 20152 0 16:30 pts/0 00:00:00 /opt/mysql5/libexec/mysqld --basedir=/opt/mysql5 --datadir=/opt/mysql5/var --user=mysql --pid-file=/opt/mysql5/var/localhost.localdomain.pid --skip-locking --port=3306 --socket=/tmp/mysql.sock
[root@localhost mysql5]#ls
[root@localhost mysql5]#bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.22-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
APACHE安装
[root@localhost ~]# cd httpd*
[root@localhost httpd-2.2.9]#ls
****INSTALL****
[root@localhost httpd-2.2.9]#vi INSTALL //查看安装步骤。
[root@localhost httpd-2.2.9]#./configure -–enable-so -–prefix=/opt/www
[root@localhost httpd-2.2.9]#make
[root@localhost httpd-2.2.9]#make install
[root@localhost httpd-2.2.9]#cd /opt/www
[root@localhost www]# ll
total 60
drwxr-xr-x 2 root root 4096 Sep 16 17:30 bin
drwxr-xr-x 2 root root 4096 Sep 16 17:31 build
drwxr-xr-x 2 root root 4096 Sep 16 17:30 cgi-bin
drwxr-xr-x 4 root root 4096 Sep 16 17:30 conf
drwxr-xr-x 3 root root 4096 Sep 16 17:30 error
drwxr-xr-x 2 root root 4096 Jun 10 15:14 htdocs
drwxr-xr-x 3 root root 4096 Sep 16 17:30 icons
drwxr-xr-x 2 root root 4096 Sep 16 17:31 include
drwxr-xr-x 4 root root 4096 Sep 16 17:30 lib
drwxr-xr-x 2 root root 4096 Sep 16 17:30 logs
drwxr-xr-x 4 root root 4096 Sep 16 17:31 man
drwxr-xr-x 14 root root 12288 Jun 10 15:18 manual
drwxr-xr-x 2 root root 4096 Sep 16 17:30 modules
测试apache
[root@localhost www]# bin/apachectl start //启动APACHE
在浏览器地址栏中打192.168.75.132
出现:It works!
说明APACHE已经开始工作。
PHP安装:
[root@localhost www]# bin/apachectl stop
[root@localhost ~]#cd php*
[root@localhost php-5.2.6]# ls
****INSTALL****
[root@localhost php-5.2.6]#vi INSTALL //查看安装步骤。
[root@localhostphp-5.2.6]#./configure -–with-apxs2=/opt/www/bin/apxs -–with-mysql=/opt/mysql
[root@localhost php-5.2.6]#make
[root@localhost php-5.2.6]#make test
[root@localhost php-5.2.6]#make install
[root@localhost php-5.2.6]# cp php.ini-dist /opt/www/lib/php.ini
[root@localhost php-5.2.6]#cd
[root@localhost ~]#cd /opt/www
[root@localhost www]# ll
[root@localhost www]# cd modules
[root@localhost modules]# ls
httpd.exp libphp5.so
[root@localhost modules]# cd ../
[root@localhost www]# ls
bin cgi-bin error icons lib man modules
build conf htdocs include logs manual
[root@localhost www]# cd conf
[root@localhost conf]# ls
extra httpd.conf.bak magic original
httpd.conf httpd.conf.wxd8482-2008-09-16 mime.types
[root@localhost conf]# vi httpd.conf
LoadModule php5_module modules/libphp5.so
添加“AddType application/x-http-d-php .php .phtml”如下
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml
[root@localhost conf]#cd
[root@localhost ~]# /opt/www/bin/apachectl start //启动APACHE
[root@localhost ~]#cd /opt/www/htdocs
[root@localhost htdocs]# vi test.php
phpinfo();
?>
在浏览器中敲入
192.168.75.135/test.php中可以看到PHP信息,说明安装完成。





最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 07:22 , Processed in 0.239608 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部