Quantcast
Channel: 碳基体
Viewing all articles
Browse latest Browse all 75

VPS ubuntu的那些事

$
0
0
周五了,该倒腾倒腾VPS了,于是换个操作系统(我果然是个不正常的宅妹,照理说应该逛taobao追动漫啥的),遵从公司产品的服务器选型,选择了ubuntu,不过用的是最新版本Ubuntu 14.04(在软件产品上,非常浮夸地追求时尚)

系统重装后,马上更新(强迫症式的喜欢update)

root@www:~# apt-get update && apt-get dist-upgrade


开始倒腾

1. 修改SSH端口 
改掉SSH 默认端口(从事安全行业的后遗症,被害妄想症)

vim /etc/ssh/sshd_config

修改端口号(键盘上盲选了几个数字)

# What ports, IPs and protocols we listen for

Port <xxxx>

service ssh restart 

这只是最最最简单地防护,要更安全的SSH,可以限制登录IP,安装暴力破解插件等

2.改变系统字符 ,支持中文 
接着改变系统字符,安装 en_US.UTF-8 zh_CN.UTF-8 locale集,避免乱码问题

root@www:~# locale-gen en_US.UTF-8

root@www:~# locale-gen zh_CN.UTF-8

root@www:~# dpkg-reconfigure locales

然后就报错了

debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline Generating locales...   en_US.UTF-8... up-to-date Generation complete.

因为没有安装 dialog

root@www:~# apt-get install dialog 

最后

root@www:~# vim ~/.bashrc

添加

export LANG=en_US.UTF-8

root@www:~# source ~/.bashrc 

reboot


现在,语言统一了,接着要时间统一,改变系统时区

3.修改VPS时区 

root@www:~#  tzselect

又报错(好想报复社会。。。)

/usr/bin/tzselect: line 171: /root/iso3166.tab: No such file or directory 

/usr/bin/tzselect: time zone files are not set up correctly


vim /usr/bin/tzselect

修改

${TZDIR=/usr/share/zoneinfo}


Ubuntu 14.04 LTS bug ,解决方案来自 http://blog.csdn.net/jintiaozhuang/article/details/38583031

ok,现在可以愉快的设置中国时区了

-bash-4.2# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5(选择亚洲)
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 9(选择中国)
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & Xinjiang
5) west Tibet & Xinjiang
#? 1(按所在地区选择)

The following information has been given:

China
east China - Beijing, Guangdong, Shanghai, etc.

Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Fri Mar 28 14:56:58 CST 2014.
Universal Time is now: Fri Mar 28 06:56:58 UTC 2014.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai

vim ~/.bashrc

增加

TZ='Asia/Shanghai'
export TZ

source  ~/.bashrc


好了,现在支持中文,是中国的时区,接下来就要搭建PPTP VPN,专门用来翻墙,这是我买vps的两大动力之一(另一个就是搭建网站,其实是想建蜜罐滴说)

4.搭建PPTP VPN,翻墙搞起
方法可以参照另一篇博客《BuyVM Debian PPTP VPN安装方法》,ubuntu上安装方法与debian一样,只要将
aptitude换成apt-get就ok了

5.搭建网站 
总有一款适合你,以apache+php+mysql为例,下面安装语句就可以完成网站搭建

apt-get install apache2
apt-get install mysql-server
apt-get install php5 php5-dev php5-mysql

apt-get install phpmyadmin

ln -s /usr/share/phpmyadmin/ /var/www/[web根目录]

记得修改MySQL的字符集为utf8是个好习惯

vim /etc/mysql/my.cnf

增加

在[client]下添加

default-character-set=utf8
在[mysqld]下添加
character_set_server=utf8

service mysql restart



6.安装版本管理软件
vps除了搭建网站,翻墙外,其他的角色就是当成一个渗透工具库了。因此首要任务就是安装版本管理工具
(1)安装svn

apt-get install subversion

(2)  安装hg

apt-get install mercurial

(3) 安装git

apt-get install git

命令补全

cp git/contrib/completion/git-completion.bash ~/.git-completion.bas

vim ~/.bashrc

添加

source  ~/.git-completion.bash

source ~/.bashrc 


7.各种脚本语言及相应的安装包管理工具
(1)python包管理器-pip

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

pip install -U setuptools

pip install -U pip

参考:https://pip.pypa.io/en/latest/installing.html

(2) perl包管理器-cpan/cpanm
非常坑爹的是在128m内存的VPS上,由于交换分区不够(vps又没有全县改变),cpan根本运行不起来,所以使用占用内存较少的cpanminus来替代

apt-get install build-essential

apt-get install perl-doc

apt-get install curl

curl -L http://cpanmin.us | perl - App::cpanminus

参考https://github.com/miyagawa/cpanminus

(3)php包管理器-pecl/pear

安装php包

apt-get install php5 php5-dev


(4)ruby包管理器

apt-get install ruby irb rdoc

gem install bundler

参考http://bundler.io/

(5)lua包管理器-luarocks
安装lua

apt-get install libreadline-dev
curl -R -O http://www.lua.org/ftp/lua-5.2.3.tar.gz
tar zxvf lua-5.2.3.tar.gz
cd lua-5.2.3
make linux test
make install

安装luarocks

wget http://luarocks.org/releases/luarocks-2.1.2.tar.gz
tar zxvf luarocks-2.1.2.tar.gz
cd luarocks-2.1.2
./configure
make install


8、其它工具
(1)rz/sz

apt-get install lrzsz

(2) openssl(很多工具都依赖于该库)

apt-get install openssl

(3) ftp

apt-get install ftp



Viewing all articles
Browse latest Browse all 75

Trending Articles