Ubutnu Server Config
1. 安装Mysql5.5
a) sudo apt-get install cmake
b) cd /var/download
c) wget http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz
d) tar xzvf mysql-5.5.20.tar.gz
e) cd mysql-5.5.20
f) cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5 #安装目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock #系统sock文件
-DDEFAULT_CHARSET=utf8 #默认字符
-DDEFAULT_COLLATION=utf8_general_ci #默认字符集
-DWITH_MYISAM_STORAGE_ENGINE=1 #安装myisam引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 #安装innodb引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 #安装memory引擎
-DWITH_READLINE=1 #快捷键功能
-DENABLED_LOCAL_INFILE=1 #允许从本地导入数据
-DMYSQL_DATADIR=/var/mysql5.5/data #数据文件存放目录
-DMYSQL_USER=mysql #默认mysql用户
g) make && make install
h) chown +w /usr/local/mysql5.5
i) chown -R mysql:mysql /usr/local/mysql5.5
j) ln -s /usr/local/mysql5.5/lib/libmysqlclient.so.16 /usr/local/lib
k) cd /var/download/mysql-5.5.20/support-files/
l) cp my-large.cnf /etc/my.cnf
m) cp mysql.server /etc/init.d/mysql
n) /usr/local/mysql5.5/scripts/mysql_install_db
--basedir=/usr/local/mysql5.5
--datadir=/usr/local/mysql5.5/data
--user=mysql\
o) vim ~/.bashrc #添加mysql环境变量
export MYSQL_HOME=/usr/local/mysql5.5
export PATH=$PATH:%MYSQL_HOME%/bin:%MYSQL_HOME%/lib
p) reboot #重启服务器使环境变量生效
q) vim ~/.bashrc #添加自定义shell命令
function start () {sudo /etc/init.d/"$1" start}
function restart () {sudo /etc/init.d/"$1" restart}
function stop () {sudo /etc/init.d/"$1" stop}
r) start mysql #启动mysql
s) mysql -uroot -p #测试mysql是否正常启动
t) stop mysql #停止mysql服务
u) mysqld_safe --skip-grant-tables #安全模式启动mysql
v) mysql -uroot
w) 修改密码
mysql > update mysql.user set password=PASSWORD('000000') where user='root'
mysql > quit
x) killall -TERM mysqld #杀死所有mysql进程
y) start mysql #重新启动mysql服务
z) mysql -uroot -p000000
2. 安装ruby1.8.7和gem1.8.24
a) find / -name *gem*
b) 使用rm -rf 或 rm #删除系统gem
c) cd /var/download
d) wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz
e) tar xzvf ruby-1.8.7.tar.gz
f) ./configure --prefix=/opt/ruby
g) make && make install #编译和安装
h) vim ~/.bashrc #修改环境变量
export RUBY_HOME=/opt/ruby
export PATH=$PATH:%RUBY_HOME%/bin
i) reboot
j) cd /var/download
k) wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.zip
l) unzip rubygems-1.8.24.zip
m) cd rubygems-1.8.24
n) ruby setup.rb
o) ruby -v
p) gem -v
3. 安装passenger3.0.18和nginx1.2.4
a) cd /var/download
b) wget http://s3.amazonaws.com/phusion-passenger/releases/passenger-3.0.18.tar.gz
c) tar xvzf passenger-3.0.18.tar.gz
d) passenger已经编译好,将他copy到生产环境就可以使用
cp -r passenger-3.0.18 /opt
e) vim ~/.bashrc #配置环境变量
export PASSENGER_HOME=/opt/passenger-3.0.18
export PATH=$PATH:%PASSENGER_HOME%/bin
f) reboot
g) passenger-install-nginx-module #下载nginx和安装nginx
h) start nginx
i) passenger -v
j) nginx -v
4. 安装php5.4.38
a) cd /var/download
b) wget http://am1.php.net/distributions/php-5.4.38.tar.gz
c) tar xzvf php-5.4.38.tar.gz
d) cd php-5.4.38
e) ./configure --prefix=/opt/php5.4
--prefix=/opt/php5.4
--with-mysql=/usr/local/mysql5.5
--with-mysqli=/usr/local/mysql5.5/bin/mysql_config
--with-pdo-mysql=/usr/local/mysql5.5
--with-config-file-path=/opt/php5.4
--with-zlib
--with-curl
--with-curlwrappers
--with-mcrypt
--with-gd
--with-openssl
--with-mhash
--with-xmlrpc
--with-jpeg-dir
--with-png-dir
--with-xpm-dir
--with-freetype-dir
--with-zlib-dir
--enable-shared
--enable-fpm
--enable-xml
--disable-rpath
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--enable-mbregex
--enable-mbstring
--enable-gd-native-ttf
--enable-pcntl
--enable-sockets
--enable-zip
--enable-soap
f) make #编译
g) make install #安装
h) cd /var/download/php-5.4.38
i) cp php-fpm /etc/init.d
j) start php-fpm
k) vim ~/.bashrc #添加环境变量
export PHP_HOME=/opt/php5.4
export PATH=$PATH:$PHP_HOME/bin:$PHP_HOME/sbin
l) reboot
5. 安装ruby各种插件
example
gem install -v=2.3.11 rails
6. 设置开机启动
example
shell > chmod u+x /etc/init.d/nginx
shell > update-rc.d -f nginx defaults
7. 取消开机启动
example
shell > update-rc.d -f nginx remove