配置编译server过程记录 博客分类: Linux MySQLRailsPHPActiveRecordZend
程序员文章站
2024-03-20 08:02:39
...
以下内容是我上次在suse10上配置服务器过程的记录,放到这里供有需要的同学参考:
目标:支持LDAP的Apache2.2+MySQL5+PHP5+Subversion1.4.2+SVNManage服务器
0、设置环境
为优化编译,需要根据CPU设置编译参数(详见http://gentoo-wiki.com/Safe_Cflags),我的是AMD的CPU。创建文件 /etc/profile.d/cflags.sh 然后重新登录 :
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=athlon-xp -msse3 -O2 -pipe -fomit-frame-pointer"
export CXXFLAGS="${CFLAGS}"
1、编译MySQL
rm -Rf /usr/local/mysql # 删除旧版本
./configure --prefix=/usr/local/mysql \
--enable-thread-safe-client \
--without-debug \
--localstatedir=/opt/mysql/data
make //编译
make install //安装
groupadd mysql
useradd -g mysql mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown –R root:root /usr/local/mysql //文件属性改为root用户
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf //复制配置文件
----------------------------------启动MySQL服务----------------------------------
/usr/local/mysql/bin/mysqld_safe --user=mysql & //启动MySQL
----------------------------------修改MySQL密码----------------------------------
/usr/local/mysql/bin/mysqladmin -uroot password mysqlsecret //修改密码
----------------------------------关闭MySQL服务----------------------------------
/usr/local/mysql/bin/mysqladmin -uroot -pmysqlsecret shutdown
#把mysql启动脚本复制到init.d目录
cp /usr/local/mysql/share/mysql.server /etc/init.d
2、编译安装Berkeley DB
为支持subversion的BDB存储方式,需要安装这个软件:
cd db-4.4.20/build_unix
../dist/configure --enable-compat185
make
make install
3、编译Apache2.2:
cd /srv/setup
tar -zxvf httpd-2.2.3.tar.gz
cd httpd-2.2.3
cd srclib/apr
./buildconf
./configure --prefix=/usr/local/apr
make && make install
cd ../apr-util
./buildconf
./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr --with-berkeley-db=/usr/local/BerkeleyDB.4.4
make && make install
./configure --prefix=/usr/local/apache2.2 \
--with-included-apr \
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr \
--with-berkeley-db=/usr/local/BerkeleyDB.4.4 \
--enable-so \
--with-ldap \
--enable-ldap \
--enable-authnz-ldap \
--enable-rewrite \
--enable-setenvif \
--enable-mime \
--enable-ssl \
--with-ssl=/usr \
--enable-headers \
--enable-dav \
--enable-dav-fs \
--enable-dav-lock \
--enable-maintainer-mode \
--enable-proxy \
--enable-proxy-http \
--enable-proxy-balancer
#编译并安装
make
make install
ln -s /usr/local/apache2.2/bin/apachectl /usr/local/bin
ln -s /usr/local/apache2.2/bin/htpasswd /usr/local/bin
ln -s /usr/local/apache2.2/bin/httpd /usr/local/bin
ln -s /usr/local/apache2.2/conf/httpd.conf /etc/httpd.conf
mv /usr/local/apache2.2/htdocs /var/www
打开/etc/httpd.conf,找到User和Group,修改为如下内容
User nobody
Group nobody
执行以下脚本设置目录权限:
chown nobody:nobody /usr/local/apache2.2 -R
可通过以下命名启动apache:
apachectl start
把启动脚本复制到init.d目录
cp /usr/local/apache2.2/bin/apachectl /etc/init.d/httpd
4、编译PHP5.2
./configure --prefix=/usr/local \
--with-config-file-path=/usr/local/apache2.2/conf \
--with-apxs2=/usr/local/apache2.2/bin/apxs \
--with-bz2=/usr \
--enable-ftp \
--enable-sockets \
--disable-ipv6 \
--with-gd=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-freetype-dir=/usr \
--with-ldap \
--with-ldap-sasl \
--enable-gd-native-ttf \
--enable-mbstring \
--with-gettext \
--with-openssl-dir=/usr \
--with-libxml=/usr \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/tmp/mysql.sock \
--enable-sqlite-utf8 \
--with-zlib=/usr \
--with-zlib-dir=/usr \
--enable-zend-multibyte
make
make install
======================================
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/include/php/ext/pdo/
cp php.ini-dist /usr/local/apache2.2/conf/php.ini
ln -s /usr/local/apache2.2/conf/php.ini /etc/php.ini
打开/usr/local/apache2.2/conf/httpd.conf,加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
5、编译安装SubVersion1.4.4
./configure --with-apxs=/usr/local/apache2.2/bin/apxs \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr \
--with-berkeley-db=/usr/local/BerkeleyDB.4.4 \
--with-swig=/usr/local
make && make install
make swig-py && make install-swig-py
ldconfig
注意!! configure时可能会出现以下问题:
An appropriate version of neon could not be found, so libsvn_ra_dav
will not be built. If you want to build libsvn_ra_dav, please either
install neon 0.25.5 on this system
or
get neon 0.25.5 from:
http://www.webdav.org/neon/neon-0.25.5.tar.gz
unpack the archive using tar/gunzip and rename the resulting
directory from ./neon-0.25.5/ to ./neon/
6.rails安装
gem install mongrel
gem install mongrel_cluster
mongrel_rails cluster::configure -e production \
-p 4000 -N 3 -c /srv/rails/pmstudio -a 127.0.0.1 \
--user nobody --group nobody
mongrel_rails cluster::start
mongrel_rails cluster::stop
如果把session配置为activerecord保存,则在/etc/crontab中加入以下代码进行定时清除过期session,下面设置的是一小时过期
/srv/rails/pmstudio/script/runner 'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 1 HOUR")'
*/3 * * * * root /srv/rails/pmstudio/script/runner 'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 1 HOUR")'
目标:支持LDAP的Apache2.2+MySQL5+PHP5+Subversion1.4.2+SVNManage服务器
0、设置环境
为优化编译,需要根据CPU设置编译参数(详见http://gentoo-wiki.com/Safe_Cflags),我的是AMD的CPU。创建文件 /etc/profile.d/cflags.sh 然后重新登录 :
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=athlon-xp -msse3 -O2 -pipe -fomit-frame-pointer"
export CXXFLAGS="${CFLAGS}"
1、编译MySQL
rm -Rf /usr/local/mysql # 删除旧版本
./configure --prefix=/usr/local/mysql \
--enable-thread-safe-client \
--without-debug \
--localstatedir=/opt/mysql/data
make //编译
make install //安装
groupadd mysql
useradd -g mysql mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown –R root:root /usr/local/mysql //文件属性改为root用户
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf //复制配置文件
----------------------------------启动MySQL服务----------------------------------
/usr/local/mysql/bin/mysqld_safe --user=mysql & //启动MySQL
----------------------------------修改MySQL密码----------------------------------
/usr/local/mysql/bin/mysqladmin -uroot password mysqlsecret //修改密码
----------------------------------关闭MySQL服务----------------------------------
/usr/local/mysql/bin/mysqladmin -uroot -pmysqlsecret shutdown
#把mysql启动脚本复制到init.d目录
cp /usr/local/mysql/share/mysql.server /etc/init.d
2、编译安装Berkeley DB
为支持subversion的BDB存储方式,需要安装这个软件:
cd db-4.4.20/build_unix
../dist/configure --enable-compat185
make
make install
3、编译Apache2.2:
cd /srv/setup
tar -zxvf httpd-2.2.3.tar.gz
cd httpd-2.2.3
cd srclib/apr
./buildconf
./configure --prefix=/usr/local/apr
make && make install
cd ../apr-util
./buildconf
./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr --with-berkeley-db=/usr/local/BerkeleyDB.4.4
make && make install
./configure --prefix=/usr/local/apache2.2 \
--with-included-apr \
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr \
--with-berkeley-db=/usr/local/BerkeleyDB.4.4 \
--enable-so \
--with-ldap \
--enable-ldap \
--enable-authnz-ldap \
--enable-rewrite \
--enable-setenvif \
--enable-mime \
--enable-ssl \
--with-ssl=/usr \
--enable-headers \
--enable-dav \
--enable-dav-fs \
--enable-dav-lock \
--enable-maintainer-mode \
--enable-proxy \
--enable-proxy-http \
--enable-proxy-balancer
#编译并安装
make
make install
ln -s /usr/local/apache2.2/bin/apachectl /usr/local/bin
ln -s /usr/local/apache2.2/bin/htpasswd /usr/local/bin
ln -s /usr/local/apache2.2/bin/httpd /usr/local/bin
ln -s /usr/local/apache2.2/conf/httpd.conf /etc/httpd.conf
mv /usr/local/apache2.2/htdocs /var/www
打开/etc/httpd.conf,找到User和Group,修改为如下内容
User nobody
Group nobody
执行以下脚本设置目录权限:
chown nobody:nobody /usr/local/apache2.2 -R
可通过以下命名启动apache:
apachectl start
把启动脚本复制到init.d目录
cp /usr/local/apache2.2/bin/apachectl /etc/init.d/httpd
4、编译PHP5.2
./configure --prefix=/usr/local \
--with-config-file-path=/usr/local/apache2.2/conf \
--with-apxs2=/usr/local/apache2.2/bin/apxs \
--with-bz2=/usr \
--enable-ftp \
--enable-sockets \
--disable-ipv6 \
--with-gd=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-freetype-dir=/usr \
--with-ldap \
--with-ldap-sasl \
--enable-gd-native-ttf \
--enable-mbstring \
--with-gettext \
--with-openssl-dir=/usr \
--with-libxml=/usr \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/tmp/mysql.sock \
--enable-sqlite-utf8 \
--with-zlib=/usr \
--with-zlib-dir=/usr \
--enable-zend-multibyte
make
make install
======================================
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/include/php/ext/pdo/
cp php.ini-dist /usr/local/apache2.2/conf/php.ini
ln -s /usr/local/apache2.2/conf/php.ini /etc/php.ini
打开/usr/local/apache2.2/conf/httpd.conf,加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
5、编译安装SubVersion1.4.4
./configure --with-apxs=/usr/local/apache2.2/bin/apxs \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr \
--with-berkeley-db=/usr/local/BerkeleyDB.4.4 \
--with-swig=/usr/local
make && make install
make swig-py && make install-swig-py
ldconfig
注意!! configure时可能会出现以下问题:
An appropriate version of neon could not be found, so libsvn_ra_dav
will not be built. If you want to build libsvn_ra_dav, please either
install neon 0.25.5 on this system
or
get neon 0.25.5 from:
http://www.webdav.org/neon/neon-0.25.5.tar.gz
unpack the archive using tar/gunzip and rename the resulting
directory from ./neon-0.25.5/ to ./neon/
6.rails安装
gem install mongrel
gem install mongrel_cluster
mongrel_rails cluster::configure -e production \
-p 4000 -N 3 -c /srv/rails/pmstudio -a 127.0.0.1 \
--user nobody --group nobody
mongrel_rails cluster::start
mongrel_rails cluster::stop
如果把session配置为activerecord保存,则在/etc/crontab中加入以下代码进行定时清除过期session,下面设置的是一小时过期
/srv/rails/pmstudio/script/runner 'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 1 HOUR")'
*/3 * * * * root /srv/rails/pmstudio/script/runner 'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 1 HOUR")'
推荐阅读
-
配置编译server过程记录 博客分类: Linux MySQLRailsPHPActiveRecordZend
-
建立虚拟用户的vsftpd安装配置过程 博客分类: Linux/Unix运维技术 虚拟用户vsftpdSFTPunix
-
建立虚拟用户的vsftpd安装配置过程 博客分类: Linux/Unix运维技术 虚拟用户vsftpdSFTPunix
-
[ffmpeg]记录一下编译ffmpeg过程中的踩坑 博客分类: 视频编解码 ffmpeg
-
linux内核编译步骤(详细全过程) 博客分类: linux linuxubuntu内核编译
-
Linux上安装GCC编译器过程 博客分类: Linux gcc
-
YACC工具ParserGenerator的下载和配置过程 博客分类: 编译原理 编译器yaccLALR文法解析C
-
Ubuntu下配置(不需启用root账号)VMware Server 2.0 博客分类: Linux VmwareUbuntuJava
-
Ubuntu下配置(不需启用root账号)VMware Server 2.0 博客分类: Linux VmwareUbuntuJava