发布于 2015-12-29 14:48:58 | 307 次阅读 | 评论: 0 | 来源: PHPERZ
这里有新鲜出炉的Nginx开发从入门到精通,程序狗速度看过来!
Nginx WEB服务器
Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。
需要安装apache
libapache2-svn模块
,nginx
,svn
。安装过程略过。
记录比较重要几点(不按先后):
安装apache的svn模块
sudo apt-get install libapache2-svn
apahce的svn模块,通过他实现svn权限等问题。
apt-get install apache2-utils
如果想通过htpasswd来给svn加(修改重置)密码,就安装apache2-utils
eg:
htpasswd /home/svn/work/conf/passwd tb
New password:
Re-type new password:
Updating password for user tb
nginx监听转发给apache请求:
nginx 监听请求转发到apache的86端口(因为不能同时占用80)
vim /etc/nginx/conf.d
server{
listen 80;
server_name svn.tb.com;
location /svn/work {
proxy_pass http://127.0.0.1:86/svn/work;
}
}
通过上述代码实现请求http://svn.tb.com/svn/work/时的正确响应。
(请求此网址是nginx响应,对应下面apache响应)
设置apache监听端口为86,尽量最小化安装,减少内存。具体可看末尾视频。
//apache 的ports.conf ,监听86端口
Listen 86
初始化svn根目录
eg:
/home/svn/work是通过sudo svnadmin create建立的目录
创建成功后目录如下:
drwxr-xr-x 2 root root 4096 1月 15 10:52 conf
drwxr-sr-x 6 root root 4096 1月 15 14:52 db
-r--r--r-- 1 root root 2 1月 15 10:50 format
drwxr-xr-x 2 root root 4096 1月 15 10:50 hooks
drwxr-xr-x 2 root root 4096 1月 15 10:50 locks
-rw-r--r-- 1 root root 246 1月 15 10:50 README.txt
apache配置设置-perfork
apache2.conf添加,第一份是优化(具体参考末尾视频)
第二份是访问监听类似http://192.168.92.247:86/svn/work/的请求,
(此网址请求为apache响应请求,对应上面nginx请求)
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 1
MaxSpareServers 1
MaxClients 10
MaxRequestsPerChild 0
</IfModule>
<Location /svn/work>
DAV svn
SVNPath /home/svn/work
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /home/svn/work/conf/passwd
AuthzSVNAccessFile /home/svn/work/conf/authz
Require valid-user
</Location>
关于svn的一些设置,比较重要的是设置权限(可参考末尾链接)
启动&检测
svnserve -d //后台启动
netstat -antp |grep svnserve或者 ps -A |grep "svn" //检测是否启动
将线上代码(未版本化的文件)初始化到版本库中
sudo svn import /usr/share/nginx/html file:///home/svn/work -m "init"
[sudo] password for tb250:
正在增加 /usr/share/nginx/html/50x.html
正在增加 /usr/share/nginx/html/index.html
正在增加 /usr/share/nginx/html/info.php
正在增加 /usr/share/nginx/html/mail.php
提交后的版本为 1。
从版本库中checkout一份代码 svn_code
sudo svn checkout file:///home/svn/work /home/tb250/svn_code
从版本库中再checkout另外一份代码 svn_code_2
sudo svn checkout file:///home/svn/work /home/tb250/svn_code_2
添加 svn add xx.php
svn status (简写 svn st)
A xx.php
svn commit -m 'add xx.php'(简写 svn ci)
更新到最新版本
svn update 简写 svn up
更新到某个版本
svn update -r numerversion
查看添加日志
svn log