添加并设置用户
添加属于我自己的用户,并添加到可以sudo的组别
root@ubuntu:/# adduser kingmax
root@ubuntu:/# usermod -a -G sudo kingmax
设置主机名:
root@ubuntu:/# vim /etc/hostname
root@ubuntu:/# hostname xxxx-new-hostname
root@ubuntu:/# vim /etc/hosts
更新源
root@ubuntu:/# vim /etc/apt/sources.list
清空,把这些内容贴进去:
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
root@ubuntu:/# apt-get update
安装Apache
root@ubuntu:/# apt-get install apache2
到浏览器上测试一下是否能打开服务器的IP了。看到这一页就是安装成功了。
增加默认输出编码:
root@ubuntu:/# vim /etc/apache2/conf-enabled/charset.conf
打开:
AddDefaultCharset UTF-8
设置主机名:
root@ubuntu:/# vim /etc/apache2/sites-enabled/000-default.conf
打开:
ServerName www.xxx.com
打开rewrite mod:
root@ubuntu:/# a2enmod rewrite
取消javascript目录的alias
root@ubuntu:/# rm /etc/apache2/conf-enabled/javascript-common.conf
做好后记得重启apache。
安装PHP
root@ubuntu:/# apt-get install php5
测试一下PHP是否正常运行了。
root@ubuntu:/# vim /var/www/html/i.php
写入如下内容:
<?php
phpinfo();
再到浏览器测试一下,打开:http://222.73.181.xxx/i.php
看到这个页面表示安装成功。
仔细看看还需要安装什么模块。我这里举两个例子,需要安装gd、curl。一般可以通过apt-cache search php5-xxx这样找到软件包的名称。
root@ubuntu:/# apt-get install php5-gd
root@ubuntu:/# apt-get install php5-curl
root@ubuntu:/# apachectl restart
再到浏览器刷新刚才的页面看看页面中是否已经出现相关模块。
配置文件,这些是我常用的php.ini配置,可以供参考:
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATEDdisplay_errors = Onmemory_limit = 1024Mmax_input_time = -1max_execution_time = 0post_max_size = 0upload_max_filesize = 1024Mshort_open_tag = On
root@ubuntu:/# vim /etc/php5/apache2/php.ini
root@ubuntu:/# vim /etc/php5/cli/php.ini
安装MYSQL
root@ubuntu:/# apt-get install mysql-server
root@ubuntu:/# apt-get install php5-mysql
root@ubuntu:/# apt-get install phpmyadmin
测试:浏览器登录 http://222.73.181.xxx/phpmyadmin/
用户名root,密码是刚刚设置那个,尝试登录。看到这个界面证明安装成功。
安装Mongo
root@ubuntu:/# apt-get install mongodb
root@ubuntu:/# apt-get install php5-mongo
安装Rockmongo
root@ubuntu:/# cd /usr/share/ && wget https://github.com/iwind/rockmongo/archive/1.1.7.zip
root@ubuntu:/usr/share# apt-get install unzip
root@ubuntu:/usr/share# unzip 1.1.7.zip
root@ubuntu:/# vim /etc/apache2/conf-enabled/rockmongo.conf
写入如下内容:
Alias /rockmongo /usr/share/rockmongo-1.1.7
保存退出,重启apache。
root@ubuntu:/# apachectl restart
测试:在浏览器登录 http://222.73.181.xxx/rockmongo/
用户名和密码均为admin,如果能看到
请注意:rockmongo的初始密码太简单,必须改掉,否则很不安全。而mongo默认又是没有密码的。
root@ubuntu:/# vim /usr/share/rockmongo-1.1.7/config.php
改这一行:
$MONGO[“servers”][$i][“control_users”][“admin”] = “admin”;//one of control users [“USERNAME”]=PASSWORD, works only if mongo_auth=false
安装SVN
root@ubuntu:/# apt-get install subversion
root@ubuntu:/# apt-get install subversion-tools
测试一下,键入这个命令,看是否有报错:
root@ubuntu:/# svn help
安装Apache SVN验证模块
root@ubuntu:/# apt-get install libapache2-svn
修改配置文件,这个是关键了,要啃一下英文,这里不详解。
root@ubuntu:/# vim /etc/apache2/mods-enabled/dav_svn.conf
我这里贴一下我的配置:
# dav_svn.conf – Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.
# <Location URL> … </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
<Location /svn>
# Uncomment this to enable the repository
DAV svn
# Set this to the path to your repository
#SVNPath /var/lib/svn
# Alternatively, use SVNParentPath if you have multiple repositories under
# under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, …).
# You need either SVNPath and SVNParentPath, but not both.
SVNParentPath /var/lib/svn
# Access control is done at 3 levels: (1) Apache authentication, via
# any of several methods. A “Basic Auth” section is commented out
# below. (2) Apache <Limit> and <LimitExcept>, also commented out
# below. (3) mod_authz_svn is a svn-specific authorization module
# which offers fine-grained read/write access control for paths
# within a repository. (The first two layers are coarse-grained; you
# can only enable/disable access to an entire repository.) Note that
# mod_authz_svn is noticeably slower than the other two layers, so if
# you don’t need the fine-grained control, don’t configure it.
# Basic Authentication is repository-wide. It is not secure unless
# you are using https. See the ‘htpasswd’ command to create and
# manage the password file – and the documentation for the
# ‘auth_basic’ and ‘authn_file’ modules, which you will need for this
# (enable them with ‘a2enmod’).
AuthType Basic
AuthName “xxxx.com Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd
# To enable authorization via mod_authz_svn (enable that module separately):
<IfModule mod_authz_svn.c>
AuthzSVNAccessFile /etc/apache2/dav_svn.authz
</IfModule>
# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the ‘authz_user’
# module (enable it with ‘a2enmod’).
#<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
#</LimitExcept>
</Location>
改完后记得重启。
root@ubuntu:/# apachectl restart
验证一下配置有没有成功,这里关键点是两个文件,一个是用户验证文件:/etc/apache2/dav_svn.passwd,一个是项目权限验证文件:/etc/apache2/dav_svn.authz,我们手动写这两个文件试试。
第一步:建立一个库。
root@ubuntu:/# svnadmin create /var/lib/svn/test4svn
更改成Apache用户的权限,以方便可以正常commit
root@ubuntu:/# chown -R www-data:www-data /var/lib/svn/test4svn
浏览器访问:http://222.73.181.xxx/svn/test4svn/
这个时候会要求你输入密码,输入完之后会有如下页面:
别着急,因为你还没有去配置那两个权限文件呢。
第二步,尝试建立权限文件
手动建立,先安装一些必要工具,再生成:
root@ubuntu:/# apt-get install apache2-utils
root@ubuntu:/# htpasswd -c /etc/apache2/dav_svn.passwd kingmax
再生成项目配置文件:
root@ubuntu:/# vim /etc/apache2/dav_svn.authz
[groups]
test4svn_group=kingmax,usernamexxx
[test4svn:/]
@test4svn_group=rw
不用重启APACHE,直接到刚才那个浏览器页面刷新吧。看到这个页面,就是配置成功了。
可以尝试一下在客户端update、commit一下。
支持SSL
尝试访问:https://222.73.181.xxx/svn/test4svn/,页面打不开。
root@ubuntu:/# a2enmod ssl
root@ubuntu:/# a2ensite default-ssl
root@ubuntu:/# service apache2 reload
看到如下界面,就是成功了!