centos 下 mysql,apache,php,subversion 安装详细过程

软件版本:
MySQL:mysql-5.1.63
Apache:httpd-2.2.22
PHP:php-5.2.17
SQLite:sqlite-3.6.16
Subversion:subversion-1.6.18

安装编译器:
yum install gcc
yum install gcc-c++
yum install ncurses-devel
yum install libtermcap-devel

用于安装apache,否则make时会报错
yum install zlib-devel

用于安装php的库
yum install gd-devel php-gd
yum install freetype-devel freetype-demos freetype-utils
yum install ImageMagick
yum install flex
yum install ImageMagick-devel
yum install curl
yum install curl-devel
yum install libxml2-devel
yum install libmcrypt
yum install libmcrypt-devel

用于安装subversion的库
yum install expat
yum install expat-devel

安装MySQL
tar zxvf mysql-xxx.tar.gz
cd mysql-xxx

./configure –prefix=/usr/local/mysql –with-charset=utf8 –with-collation=utf8_general_ci –with-extra-charsets=gbk,latin1 –enable-thread-safe-client –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-unix-socket-path=/tmp/mysql.sock –sysconfdir=/etc –disable-shared –without-debug –with-pthread

参数详解
–prefix=/usr/local/mysql 将MySQL安装到“/usr/local/mysql”目录
–with-charset=utf8 改变默认字符集
–with-collation=utf8_general_ci 默认校对规则
–enable-thread-safe-client 以线程方式编译客户端
–with-extra-charsets=gb2312,latin1 添加gb2312,latin1字符支持
–with-client-ldflags=-all-static 以纯静态方式编译客户端
–with-mysqld-ldflags=-all-static 以纯静态方式编译服务端
–enable-assembler 使用一些字符函数的汇编版本
–with-unix-socket-path=/tmp/mysql.sock 将MySQL的Unix套接字放于/tmp目录
–sysconfdir=/etc 设置MySQL的配置文件目录
–disable-shared 不构造共享libmysqlclient.so库
–without-debug 去除debug模式
–with-pthread 强制使用pthread库(posix线程库)

编译安装
make
make install

为mysqld增加一个登录用户和组
groupadd mysql
useradd  mysql -g mysql  -s /bin/false

复制配置文件和启动文件
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 0700 /etc/rc.d/init.d/mysqld

将mysql添加为服务,并设置mysql开机启动
chkconfig –add mysqld
chkconfig –level 345 mysqld on

安装初始化数据
mkdir /usr/local/mysql/data
pushd /usr/local/mysql
bin/mysql_install_db –user=mysql –datadir=/usr/local/mysql/data
popd

设置所有者,mysql起动时会以mysql用户的身份运行,这样可以提高系统的安全性。
cd /usr/local
chmod 0750 mysql -R
chown -R mysql.mysql /usr/local/mysql

修改/etc/rc.d/init.d/mysqld中的
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

service mysqld start
# 启动mysql服务

./mysqladmin -uroot password “*******”
# 设置root帐户的密码

mysql -uroot -p
mysql>use mysql;
mysql>delete from user where password=””;
# 删除用于本机匿名连接的空密码帐号

安装apache
tar zxvf httpd-xxx.tar.gz
cd httpd-xxx

./configure –prefix=/usr/local/apache2 –enable-so –enable-mods-shared=all –with-mpm=prefork –enable-dav-fs

参数详解
–prefix=/usr/local/apache2 将apache安装到“/usr/local/apache2”目录
–enable-so 支持DSO(动态共享对像)
–enable-mods-shared=all 将所有模块都编译成DSO
–with-mpm=prefork apache跑worker模式貌似不稳定,采用稳定的prefork模式
–enable-dav-fs 开启WebDAV支持,svn服务器等需要

make
make install

cp support/apachectl /etc/rc.d/init.d/httpd
vi /etc/rc.d/init.d/httpd

在httpd文件的第三行,插入以下两句话:
#chkconfig: 345 85 15
#description: Starts and stops the Apache HTTP Server.

然后执行下面的命令,让apache随机启动

chmod +x /etc/rc.d/init.d/httpd
chkconfig –add httpd
chkconfig –level 345 httpd on
chkconfig –level 0126 httpd off

可以尝试执行下面的命令来启动apache
service httpd start

安装PHP
tar zxvf php-xxx.tar.gz
cd php-xxx

./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-config-file-path=/usr/local/php5 –with-gd –with-jpeg-dir –with-png-dir –with-ttf –with-zlib –enable-mbstring –enable-ftp –with-freetype-dir –with-curl –with-libxml-dir –with-xmlrpc –enable-xml –enable-magic-quotes –enable-sockets –with-mcrypt –enable-bcmath –with-openssl –enable-soap

make
make test
make install

cp php.ini-dist /usr/local/php5/php.ini

vi /usr/local/apache2/conf/httpd.conf
加上:
AddType application/x-httpd-php .php
查找DirectoryIndex,修改为
DirectoryIndex index.html index.php

安装sqlite,subversion需要sqlite
tar -zxvf sqlite-3.6.16.tar.gz
cd sqlite-3.6.16
./configure –prefix=/usr/local/sqlite
make
make install

安装subversion
tar zxvf subversion-xxx.tar.gz
cd subversion-xxx

./configure –prefix=/usr/local/subversion –with-apxs=/usr/local/apache2/bin/apxs –with-apr=/usr/local/apache2 –with-apr-util=/usr/local/apache2
make
make install

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据