yardvps配置手记

I.新建用户(test):

购买vps时只有root一个用户,ubuntu上习惯用普通用户:

1、输入用户管理的命令,新建用户(以test为例):

useradd test

修改 test 用户的密码:

passwd test

2、将新用户添加到管理组:

gpasswd -a test admin

3、给 test 用户创建自己的目录:

cd /home

	mkdir test

	chown test /home/test

4、添加sudoer权限:

vim /etc/sudoers文件。找到这一 行:”root ALL=(ALL) ALL”在起下面添加”xxx ALL=(ALL) ALL”(这里的xxx是你的用户名),保存退出.

5、指定shell:

vim /etc/passwd,找到相应的用户,指定shell路径:/bin/bash

II.OPENVPN:

1、安装:

sudo apt-get installl openvpn

2、准备和安装:

sudo cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/ /etc/openvpn/
	cd /etc/openvpn/2.0/
	sudo vim vars
	su (切换到root,用普通用户老出错)
	source vars
	./clean-all
	./build-ca
	./build-key-server server
	./build-key client1
	./build-dh

3、配置:

sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn
	cd /etc/openvpn
	sudo gzip -d server.conf.gz
	sudo vim server.conf

4、配置nat转发:

sudo bash
	sudo echo 1 > /proc/sys/net/ipv4/ip_forward
	sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 

-j MASQUERADE
	
	iptables-save > /etc/iptables.up.rules
	sudo vim /etc/network/interfaces
	最后添加:
	pre-up iptables-restore < /etc/iptables.up.rules

If you made a mistake and want to remove all rules from IPTables:

sudo iptables -F -t nat

III. Apache:

1、安装:

下载源码包,解压。

cd httpd-xxx
	sudo ./configure --prefix=/usr/local/apache2 –-enable-mem-cache –-enable-vhost-alias --enable-cache -with-ssl --enable-ssl --enable-so --enable-rewrite --enable-mime-magic
	sudo make
	sudo make install

IV. Mysql:

sudo apt-get install cmake libncurses5-dev build-essential g++ sysv-rc-conf
(centos6 : yum install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel*)
	sudo cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
	sudo make
	sudo make install
	cd /usr/local/mysql
	sudo chown -R mysql .
	sudo chgrp -R mysql .
	sudo ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --no-defaults
	sudo cp /usr/local/mysql/support-files/my-medium.cnf /etc/mysql/my.cnf
	sudo vim /etc/mysql/my.cnf
	在[mysqld]下添加:
	basedir=/usr/local/mysql
	datadir=/usr/local/mysql/data
	user=mysql

	sudo /usr/local/mysql/support-files/mysql.server start

(如果能启动成功,则说明配置成功)

配置开机启动:

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
	sudo sysv-rc-conf

找到【mysql】一栏,选定【3】【4】【5】这三列

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 veapon.com password 'new-password'

V. PHP:

sudo apt-get install -y libltdl-dev libssl-dev sendmail libjpeg8 libjpeg8-dev libpng12-0  libpng12-dev libxml2-dev libcurl4-openssl-dev libmcrypt-dev
	sudo ln -s /usr/lib/x86_64-linux-gnu/libpng* /usr/lib/
	cd php-xxx
	sudo ./configure --prefix=/usr/local/php --with-curl --with-mcrypt --enable-mbstring --enable-pdo --with-openssl --with-imap-ssl --with-gd --with-jpeg-dir=/usr/lib/ --with-png-dir=/usr/lib/ --enable-exif --enable-zip --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
	sudo make
	sudo make install
	sudo cp php.ini-development /usr/local/php/lib/php.ini
	sudo vim /usr/local/apache2/conf/httpd.conf

适当位置加入:

AddType application/x-httpd-php .php

安装mysqli扩展

sudo apt-get install autoconf
	cd /path/to/php-source/ext/mysqli
        sudo /usr/local/php/bin/phpize
	sudo ./configure --prefix=/usr/local/php/include/php/ext/mysqli --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/local/mysql/bin/mysql_config
	sudo vim /usr/local/php/lib/php.ini

加入:

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/mysqli.so

VI. subversion:

sudo apt-get install subversion subversion-tools
	sudo mkdir /var/svn/test
	sudo svnadmin create /var/svn

修改配置:

sudo vim /var/svn/test/conf/svnserver.conf
	#匿名访问的权限,可以是read,write,none,默认为read
	anon-access = none
	#认证用户的权限,可以是read,write,none,默认为write
	auth-access = write
	#账号数据库
	password-db = passwd

添加账号:

sudo vim /var/svn/test/conf/passwd
	#格式:用户名 = 密码
	user = passwd

修改权限:

chmod -R 755 /var/svn/test

VII. Memcache:
1.安装libevent:

sudo wget https://github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz
sudo tar -zvxf libevent-2.0.17-stable.tar.gz
cd libevent-xxx
sudo ./configure
sudo make && sudo make install
sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib

2.memcached服务端:

sudo wget http://memcached.googlecode.com/files/memcached-x.xx.x.tar.gz
sudo mkdir /usr/local/memcached
sudo tar -zvxf memcached-xxx.tar.gz
cd memcached-xxx
sudo ./configure --prefix=/usr/local/memcached
sudo make && sudo make install
/usr/local/memcached/bin/memcached -h

3.php memcache扩展

sudo wget http://pecl.php.net/get/memcache-2.2.6.tgz
sudo tar -zvxf memcache-x.x.x.tgz  
cd memcache-1.5  
sudo /usr/local/php/bin/phpize  
sudo ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir  
sudo make  
sudo make install  
sudo vim /usr/local/php/lib/php.ini

加入:

extension=/usr/local/php/lib/php/extensions/no-debug-zts-20090626/memcache.so
sudo /usr/local/apahce2/bin/apachectl -k restart