外网游戏服环境搭建脚本

#!/bin/sh
#本脚本用于安装外网服务器
#安装在Centos5.10及以上版本的纯净机里
#主要实现以下功能:
#   1.下载安装G++ C++编译环境
#   2.命令行工具、拼写工具
#   3.安装MySQL  
#   4.安装PHP
#   5.安装Nginx
#   6.安装Rsync同步工具       
echo "安装g++ gcc-c++  curses...."

yum -y install g++
yum -y install gcc-c++
yum -y install ncurses    
yum -y install ncurses-devel
    
echo "创建本地游戏目录"
mkdir /data
mkdir /data/nginx_logs/
mkdir /data/game/
mkdir /data/game/Server/
mkdir /data/www/
mkdir /data/www/MuArt/
mkdir /data/www/game_web/

echo "安装 gamin..."
yum -y install gamin
yum -y install gamin-devel

echo "安装 gflags..."
tar -xzvf gflags-2.0.tar.gz
cd gflags-2.0
  ./configure
make && make install
cd ..

echo "安装 boost..."
cd boost
rpm -ivh boost-test-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-regex-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-math-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-date-time-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-system-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-filesystem-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-graph-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-serialization-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-signals-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-python-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-program-options-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-iostreams-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-thread-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-wave-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-1.39.0-9.el5.x86_64.rpm --nodeps
rpm -ivh boost-devel-1.39.0-9.el5.x86_64.rpm --nodeps

cd ..

echo /usr/local/lib >> /etc/ld.so.conf
ldconfig

echo "安装mysql开发版*********这个步骤一定一定不能少!!!!************"
mkdir /data
yum -y install mysql-devel

echo "安装 mysql.."
tar -xzvf mysql-5.0.95.tar.gz
cd mysql-5.0.95

./configure --prefix=/usr/local/mysql --datadir=/data/mysql --enable-thread-safe-client --without-isam --without-bench --without-innodb --enable-ssembler   CFLAGS="-m64 -fPIC" CXX=gcc CXXFLAGS="-m64 -felide-constructors -fno-rtti -fPIC"

make && make install

#复制已经做好的mysql配置文件到etc下面
cd ..
cp my.cnf /etc/my.cnf
cd mysql-5.0.95
cp support-files/mysql.server /etc/init.d/mysqld
#增加mysql用户、用户组
groupadd mysql

useradd -g mysql mysql
#给予授权
chown -R root /usr/local/mysql  

chgrp -R mysql /usr/local/mysql

cd /usr/local/mysql

chown mysql.mysql -R .

chown mysql.mysql -R /data/mysql

chmod 777 /etc/init.d/mysqld

bin/mysql_install_db --user=mysql --datadir=/data/mysql
#开启服务
service mysqld start
#添加MySQL服务的自启动
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
#将MySQL设置绝对路径
echo PATH=$PATH:$HOME/bin:/usr/local/mysql/bin >> /etc/profile

export PATH

 . /etc/profile
 
 cd  -
 
 cd ..
 #授权密码登陆
 /usr/local/mysql/bin/mysqladmin -u root password 123456
 #授权数据库本机以密码123456登陆
mysql -uroot -p123456 < grant.sql

echo "安装libxm及开发版"
yum -y install libxml2
yum -y install libxml2-devel

echo "安装curl开发版"
yum -y install curl-devel

echo "安装PHP"
tar -zxvf php-5.5.12RC1.tar.gz
cd php-5.5.12RC1
#配置时支持MySQL(MySQL的路径一定要正确),并安装PHP管理器PHP-fpm
./configure --prefix=/usr/local/php --enable-cgi --enable-fpm --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/usr/local/mysql --with-mysql=/usr/local/mysql --enable-sockets --with-curl --enable-mbstring
make && make install
cp php.ini-production /usr/local/php/lib/php.ini
#创建fpm的配置文件,源码包中已经自带了一个默认的配置文件这需要将配置文件改名即可使用
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
echo "启动PHP"
/usr/local/php/sbin/php-fpm
echo "设置PHP的开机自启动"
echo /usr/local/php/sbin/php-fpm>> /etc/rc.d/rc.local
cd ..

echo "安装nginx"
yum -y install pcre-devel
tar -zxvf nginx-1.2.9.tar.gz
cd nginx-1.2.9
 ./configure --prefix=/usr/local/nginx
make && make install
 cd ..
 echo "设置nginx的开机自启动"
 echo /usr/local/nginx/sbin/nginx >> /etc/rc.d/rc.local
 echo "删除nginx默认的conf并将已经写好的conf复制到对应目录"
 rm -rf /usr/local/nginx/conf/nginx.conf
 cp nginx.conf /usr/local/nginx/conf/nginx.conf
 #这一份nginx配置表的根目录是 /data/www/
 echo "启动nginx"
 /usr/local/nginx/sbin/nginx

 chmod -R 777 /data
 
echo "安装RS同步工具"
 tar -zxvf rsync-3.1.1.tar.gz
 cd rsync-3.1.1
 ./configure --prefix=/usr/local/rsync
make && make install
#这里的密码是根据服务器的密码来写入的,如果服务器修改了密码,脚本这里做一下相应的修改即可
echo "创建密码文件,默认密码是datacenter服务端的密码:963852"
touch /etc/rsync.pas
echo 963852 >> /etc/rsync.pas
echo "修改授权"
chmod 600 /etc/rsync.pas

mkdir /etc/rsync/
touch /etc/rsync/exclude_client.conf

echo "配置环境变量"
echo cd /data/ >> ~/.bashrc
echo ulimit -u 102400 >> ~/.bashrc
echo ulimit -n 102400 >> ~/.bashrc
echo ulimit -d unlimited >> ~/.bashrc
echo ulimit -m unlimited >> ~/.bashrc
echo ulimit -s unlimited>> ~/.bashrc
echo ulimit -t unlimited>> ~/.bashrc
echo ulimit -v unlimited>> ~/.bashrc
echo ulimit -c unlimited>> ~/.bashrc

echo "安装完毕"

posted on 2018-04-02 14:52  隔壁小老王  阅读(233)  评论(0编辑  收藏  举报

导航