Skip to content

Instantly share code, notes, and snippets.

@crossai-2033
Last active August 29, 2015 14:08
Show Gist options
  • Save crossai-2033/a81500b1cfb7f2a12269 to your computer and use it in GitHub Desktop.
Save crossai-2033/a81500b1cfb7f2a12269 to your computer and use it in GitHub Desktop.
linux环境安装脚本
#!/bin/bash
build_dir=$HOME/tmp/build
pkg_root=/data/pkgs/source
pkg_dst_root=/usr/local
if [ -d $build_dir ]
then
rm -rf $build_dir
fi
mkdir $build_dir
# #第一步 安装基础依赖包
sudo yum -y install ncurses-devel
sudo yum -y install pcre-devel
sudo yum -y install openssl-devel
sudo yum -y install cmake
sudo yum -y install libxml2-devel
sudo yum -y install libmcrypt-devel
sudo yum -y install net-snmp-devel
sudo yum -y install libcurl-devel
sudo yum -y install gcc
# 第二步安装vim74
cd $build_dir
tar jxvf $pkg_root/vim-7.4.tar.bz2
cd vim74
./configure --prefix=/usr/local/vim74 --enable-cscope --enable-multibyte --with-features=big
if [ $? -ne 0 ]
then
exit
fi
make
if [ $? -ne 0 ]
then
exit
fi
sudo make install
cd $pkg_dst_root
sudo ln -s vim74 vim
# 安装luaJIT
cd $build_dir
tar zxvf $pkg_root/LuaJIT-2.0.3.tar.gz
cd LuaJIT-2.0.3
sudo make install PREFIX=/usr/local/luajit-2.0.3
if [ $? -ne 0 ]
then
exit
fi
cd $pkg_dst_root
sudo ln -s luajit-2.0.3 luajit
# 安装Nginx并编译luajit模块
export LUAJIT_LIB=/usr/local/luajit/lib/
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0/
cd $build_dir
tar zxvf $pkg_root/nginx/nginx-1.2.9.tar.gz
cd nginx-1.2.9
mkdir module_src
cd module_src
tar zxvf $pkg_root/nginx/modules/ngx_devel_kit-0.2.19.tgz
tar zxvf $pkg_root/nginx/modules/ngx_lua-0.9.7.tgz
tar zxvf $pkg_root/nginx/modules/ngx_echo-0.53.tgz
cd ..
./configure --prefix=/usr/local/nginx-1.2.9 --with-http_ssl_module --with-http_gzip_static_module --with-ld-opt="-Wl,-rpath,$LUAJIT_LIB" --add-module=/home/liangchao/tmp/build/nginx-1.2.9/module_src/ngx_devel_kit-0.2.19/ --add-module=/home/liangchao/tmp/build/nginx-1.2.9/module_src/lua-nginx-module-0.9.7/ --add-module=/home/liangchao/tmp/build/nginx-1.2.9/module_src/echo-nginx-module-0.53/ --with-debug
if [ $? -ne 0 ]
then
exit
fi
make
if [ $? -ne 0 ]
then
exit
fi
sudo make install
cd $pkg_dst_root
sudo ln -s nginx-1.2.9 nginx
cd nginx
sudo mkdir pid
sudo mv conf conf_original
sudo ln -s /data/conf/nginx conf
sudo rmdir logs
sudo mkdir -p /data/logs/nginx
sudo ln -s /data/logs/nginx logs
# 安装mysql
sudo groupadd mysql
sudo useradd -r -g mysql mysql
cd /etc
sudo ln -s /data/conf/mysql/my-medium.cnf my.cnf
cd $build_dir
tar zxvf $pkg_root/mysql-5.5.38.tar.gz
cd mysql-5.5.38
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.38 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLE_DTRACE=OFF
if [ $? -ne 0 ]
then
exit
fi
make
if [ $? -ne 0 ]
then
exit
fi
sudo make install
cd $pkg_dst_root
sudo ln -s mysql-5.5.38 mysql
cd mysql
sudo mkdir -p /data/mysql
sudo mv data/* /data/mysql
sudo chown -R mysql:mysql /data/mysql
sudo rmdir data
sudo ln -s /data/mysql data
sudo ./scripts/mysql_install_db --user=mysql
sudo ./bin/mysqld_safe --user=mysql & ./bin/mysqladmin -u root password 123
# 安装php以及扩展
cd $build_dir
tar zxvf $pkg_root/libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
if [ $? -ne 0 ]
then
exit
fi
make
if [ $? -ne 0 ]
then
exit
fi
sudo make install
# 安装php以及扩展
cd $build_dir
tar jxvf $pkg_root/php-5.3.28.tar.bz2
cd php-5.3.28
# 注意centeos下我使用512内存编译会出virtual memory exhausted: Cannot allocate memory错误,解决方案为https://bugs.php.net/bug.php?id=48809 添加--disable-fileinfo
./configure --prefix=/usr/local/php-5.3.28 --enable-fpm --disable-fileinfo --enable-pcntl --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-zlib --with-openssl --with-mhash --enable-mbstring --with-mcrypt --with-snmp --enable-soap --enable-sockets --with-pear --with-config-file-path=/usr/local/php/etc
if [ $? -ne 0 ]
then
exit
fi
make
if [ $? -ne 0 ]
then
exit
fi
sudo make install
cd $pkg_dst_root
sudo ln -s php-5.3.28 php
cd php
sudo mkdir extensions
cd etc
sudo ln -s /data/conf/php/php-fpm.conf.default php-fpm.conf
sudo ln -s /data/conf/php/php.ini-development php.ini
cd $build_dir/php-5.3.28/ext
cd curl
phpize
./configure
if [ $? -ne 0 ]
then
exit
fi
make
if [ $? -ne 0 ]
then
exit
fi
sudo cp modules/curl.so $pkg_dst_root/php/extensions/
cd ../pdo_mysql
phpize
./configure --with-pdo-mysql=$pkg_dst_root/mysql
if [ $? -ne 0 ]
then
exit
fi
make
if [ $? -ne 0 ]
then
exit
fi
sudo cp modules/pdo_mysql.so $pkg_dst_root/php/extensions/
cd $build_dir
tar zxvf $pkg_root/redis/redis-2.8.11.tar.gz
cd redis-2.8.11
make
if [ $? -ne 0 ]
then
exit
fi
sudo make PREFIX=/usr/local/redis-2.8.11 install
cd $pkg_dst_root
sudo ln -s redis-2.8.11 redis
cd redis
sudo mkdir -p /data/redis
sudo ln -s /data/redis data
sudo ln -s /data/conf/redis/redis.conf redis.conf
cd $build_dir
tar zxvf $pkg_root/redis/phpredis.tgz
cd phpredis
phpize
./configure
if [ $? -ne 0 ]
then
exit
fi
make
sudo cp modules/redis.so /usr/local/php/extensions/
# Node环境安装
# 通过NVM安装并进行版本管理
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment