配置服务器CentOS

root帐号登录服务器

查看版本
cat /etc/issue
#CentOS release 5.2 (Final)
调整时区时间
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
sudo /usr/sbin/ntpdate us.pool.ntp.org
很简单吧,解析一下,第一句是把当前时区调整为上海就是+8区,想改其他时区也可以去看看/usr/share/zoneinfo目录;然后第二句 是利用ntpdate同步标准时间.
没有ntpdate的可以yum一下: yum install -y ntpdate

新建用户
useradd app
passwd app
#Changing password for user app.
#New UNIX password:
#Retype new UNIX password:
#passwd: all authentication tokens updated successfully.

#add app to sudoer
nano /etc/sudoers

#add line
app     ALL=(ALL)NOPASSWD:ALL

#test
su app
sudo ls -all

配置自动登录
su app
cd /home/app/
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

#回到本地机器
cd ~
#生成密钥对:
#ssh-keygen -t rsa
cat  ~/.ssh/id_rsa.pub | ssh app@123.152.56.151 "cat - >> ~/.ssh/authorized_keys"

#test
ssh app@123.152.56.151
配置DNS服务器
nano /etc/resolv.conf
#add
search localdomain
nameserver 208.33.222.222
nameserver 208.33.220.220

安装软件
iostat, sar等系统命令

sudo yum install sysstat
Git

sudo yum -y install zlib-devel

mkdir src
cd src
wget http://www.kernel.org/pub/software/scm/git/git-1.6.3.tar.gz
tar xf git-1.6.3.tar.gz
cd git-1.6.3
./configure --prefix=/usr/local/git

make
sudo make install
cd /usr/bin/
sudo ln -ns /usr/local/git/bin/git
git --version

openssl
(http://www.openssl.org/source/)

cd
cd src
wget http://www.openssl.org/source/openssl-0.9.8i.tar.gz
tar zxvf openssl-0.9.8i.tar.gz
cd openssl-0.9.8i/
./config shared --prefix=/usr/local
make
sudo make install
cd ..



zlib
(http://zlib.net/)

cd
cd src
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
CFLAGS="-O3 -fPIC" ./configure
make
sudo make install
cd ..



Redline
(http://tiswww.case.edu/php/chet/readline/rltop.html)

cd
cd src
wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar zxvf readline-5.2.tar.gz
cd readline-5.2
./configure
make
sudo make install
cd ..


Ruby1.9

cd
cd src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p129.tar.gz
tar xzf ruby-1.9.1-p129.tar.gz
cd ruby-1.9.1-p129
./configure
make
sudo make install

cd ext/readline
ruby extconf.rb
make
sudo make install
cd ../../../


Ruby1.8.7

cd
cd src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.bz2
tar xjf ruby-1.8.7-p249.tar.bz2
cd ruby-1.8.7-p249
./configure
make
sudo make install


#等其他装好了之后装这个。

cd ext/readline
ruby extconf.rb
make
sudo make install



rubygems

cd
cd src
wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz
tar xzf rubygems-1.3.4.tgz
cd rubygems-1.3.4
sudo ruby setup.rb
cd ..


MySQL

#安装依赖 for error :http://webhostingneeds.com/Configure:_error:_No_curses_termcap_library_found
sudo yum -y install ncurses-devel


sudo /usr/sbin/groupadd mysql
sudo /usr/sbin/useradd -g mysql mysql

version 5.1.37:

cd
cd src
wget http://mirrors.dedipower.com/www.mysql.com/Downloads/MySQL-5.1/mysql-5.1.43.tar.gz
tar xzf mysql-5.1.43.tar.gz
cd mysql-5.1.43
./configure --prefix=/usr/local/mysql --with-plugins=innobase
make
sudo make install

sudo cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
sudo bin/mysql_install_db --user=mysql

sudo chown -R root /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/var
sudo chgrp -R mysql /usr/local/mysql

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

cd /usr/bin
sudo ln -s /usr/local/mysql/bin/mysql

#等待几秒
/usr/bin/mysqladmin -u root password 'new-password'

#test
cd /usr/local/mysql/mysql-test ;sudo perl mysql-test-run.pl


------
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h alimonitor3.alimonitor.com password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

The latest information about MySQL is available at <a href="http://www.mysql.com/">http://www.mysql.com/</a>
Support MySQL by buying support/licenses from <a href="http://shop.mysql.com/">http://shop.mysql.com/</a>
------

Nginx

#with perl
cd
cd src
wget http://nchc.dl.sourceforge.net/sourceforge/pcre/pcre-7.5.tar.gz
tar zxvf pcre-7.5.tar.gz
cd pcre-7.5
./configure
make
cd ..

cd
cd src
wget http://sysoev.ru/nginx/nginx-0.7.61.tar.gz
tar xzf nginx-0.7.61.tar.gz
cd nginx-0.7.61
./configure --with-pcre=../pcre-7.5
make
sudo make install
cd ..
sudo ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx

ImageMagick

cd
cd src
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz
tar xzvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local
make
sudo make install
cd ..

cd
cd src
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.38.tar.bz2
tar jxvf libpng-1.2.38.tar.bz2
cd libpng-1.2.38
./configure --prefix=/usr/local
make
sudo make install
cd ..

cd
cd src
wget ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
tar xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --enable-shared --prefix=/usr/local
make
sudo make install
cd ..

wget ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz
tar xzvf tiff-3.8.2.tar.gz
cd tiff-3.8.2
./configure --prefix=/usr/local
make
sudo make install
cd ..

cd
cd src
wget http://jaist.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz
tar xzvf libwmf-0.2.8.4.tar.gz
cd libwmf-0.2.8.4
./configure --prefix=/usr/local
make
sudo make install
cd ..

cd
cd src
wget http://www.littlecms.com/lcms-1.17.tar.gz
tar xzvf lcms-1.17.tar.gz
cd lcms-1.17
./configure --prefix=/usr/local
make
sudo make install
cd ..

cd
cd src
wget ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs860/ghostscript-8.60.tar.gz
(http://sourceforge.net/project/showfiles.php?group_id=1897&package_id=108733)
tar zxvf ghostscript-8.60.tar.gz
cd ghostscript-8.60/
./configure  --prefix=/usr/local
make
sudo make install
cd ..

cd
cd src
wget http://jaist.dl.sourceforge.net/sourceforge/ghostscript/ghostscript-fonts-std-8.11.tar.gz
tar zxvf ghostscript-fonts-std-8.11.tar.gz
sudo mv fonts /usr/local/share/ghostscript

cd
cd src
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xzvf ImageMagick.tar.gz
cd ImageMagick-6.5.4-10/
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts
make
sudo make install
cd ..

#test
convert -h
Set .gemrc

cd
nano .gemrc

---
:bulk_threshold: 1000
:benchmark: false
:verbose: true
:sources:
- http://gems.rubyforge.org/
- http://gems.github.com
:update_sources: true
:backtrace: false
gem: --no-ri --no-rdoc
Gems

sudo gem install rails mongrel mongrel_cluster mini_magick packet RedCloth memcache-client cached_model fastercsv httparty whois googlepagerank soap4r adwords4r geoip json mash ruby-debug daemons

-------
cd /usr/lib/mysql
sudo ln -s libmysqlclient.so.15.0.0 libmysqlclient.so


nano /etc/ld.so.conf
在后面加入(libcrypto.so.0.9.8在/usr/local/lib下):
/usr/lib/mysql

#sudo gem install mysql -- --with-opt-dir=/usr/local/mysql
sudo gem install mysql -- --with-opt-include=/usr/local/mysql/include/mysql --with-opt-lib=/usr/local/mysql/lib/mysql

---------

#ruby_mysql for ruby 1.9
wget http://tmtm.org/downloads/mysql/ruby/mysql-ruby-2.8.1.tar.gz
tar xzf mysql-ruby-2.8.1.tar.gz
cd mysql-ruby-2.8.1
ruby extconf.rb -- --with-mysql-dir=/usr/local/mysql
make
sudo make install

Passenger

sudo gem install passenger
sudo passenger-install-nginx-module
设置Alias
cd ~
nano .bashrc
------------
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

alias vb='vi ~/.bash_profile;. ~/.bash_profile'


alias ll='ls -all --color'
alias n='sudo nano -w'

alias startmysql='sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &'
alias sql='mysql -uroot -padmin123 --default-character-set=utf8'


# alias gp='git push origin master'
alias irbg='irb -rubygems'
alias gb='git branch'
alias gs='git status'
alias gc='git checkout'
alias gac='git add .;git commit'
alias gm='git merge'
alias gp='git push'
alias gl='git pull'
alias gi='~/bin/git-info.sh'
alias gw='git-instaweb -d webrick -p 8888'
alias gws='gw --stop'

#tail
alias t='tail -f -n 200'

#god
alias gods='god status'
alias grun='god start'
alias gstop='god stop'
# User specific aliases and functions


mkdir bin
nano bin/git-info.sh

------
#!/bin/bash

# author: Duane Johnson
# email: duane.johnson@gmail.com
# date: 2008 Jun 12
# license: MIT
#
# Based on discussion at <a href="http://kerneltrap.org/mailarchive/git/2007/11/12/406496">http://kerneltrap.org/mailarchive/git/2007/11/12/406496</a>

pushd . >/dev/null

# Find base of git directory
while [ ! -d .git ] && [ ! `pwd` = "/" ]; do cd ..; done

# Show various information about this git directory
if [ -d .git ]; then
  echo "== Remote URL: `git remote -v`"

  echo "== Remote Branches: "
  git branch -r
  echo

  echo "== Local Branches:"
  git branch
  echo

  echo "== Configuration (.git/config)"
  cat .git/config
  echo

  echo "== Most Recent Commit"
  git log --max-count=1
  echo

  echo "Type 'git log' for more commits, or 'git show' for full commit details."
else
  echo "Not a git repository."
fi

popd >/dev/null
-------

chmod +x bin/git-info.sh
Error
cannot restore segment prot after reloc: Permission denied


To Temporarily disable enforcement on a running system

/usr/sbin/setenforce 0


To permanently disable enforcement during a system startup
change "enforcing" to "disabled" in ''/etc/selinux/config'' and reboot.
.
By default, CentOS 5 has the SE Linux feature set to "enforcing". We are looking into ways to removing these steps.


#- /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
#/usr/local/lib/libz.a: could not read symbols: Bad value
#collect2: ld returned 1 exit status
#- su -
#- cd /usr/local/src/zlib-1.2.3/
#- # -O3 was used when I first build zlib, so add it again
#- CFLAGS="-O3 -fPIC" ./configure
#- # exit su shell
#- exit
#- sudo make
#- sudo make install


/usr/local/lib/ruby/1.8/x86_64-linux/digest/md5.so: libcrypto.so.0.9.8: cannot open shared object file: No such file or directory - /usr/local/lib/ruby/1.8/x86_64-linux/digest/md5.so (LoadError)


nano /etc/ld.so.conf
在后面加入(libcrypto.so.0.9.8在/usr/local/lib下):
/usr/local/lib


然后在命令行运行
/sbin/ldconfig


-----
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [mysql_api.so] Error 1


cd /usr/lib/mysql
sudo ln -s libmysqlclient.so.15.0.0 libmysqlclient.so


nano /etc/ld.so.conf
在后面加入(libcrypto.so.0.9.8在/usr/local/lib下):
/usr/lib/mysql

sudo /sbin/ldconfig

配置iptables
su root

vim /etc/sysconfig/iptables
#add line
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

/sbin/service iptables stop
/sbin/service iptables start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值