❶ viewvc 怎麼安裝 linux
1、將/usr/local/subversion這個文件夾備份一下
mv /usr/local/subversion /usr/local/subversion.bak
2、安裝python
由於viewVC使用python寫的,而系統自帶的版本太低,因此安裝該版本。
tar xvzf Python-2.7.6.tgz
cd Python-2.7.6
./configure --prefix=/usr/local/python2
make && make install
3、安裝swig
tar xzvf swig-1.3.24.tar.gz
cd SWIG-1.3.24
./configure --prefix=/usr/local/swig \
--with-python=/usr/local/python2/bin/python
make && make install
4、安裝svn
tar xzvf subversion-1.6.18.tar.gz
tar xzvf subversion-deps-1.6.18.tar.gz
tar xzvf neon-0.29.6.tar.gz
tar xzvf serf-0.3.0.tar.bz2
cd subversion-1.6.18
rm -rf apr apr-util neon serf
cp -ar ../neon-0.29.6 neon
cp -ar ../serf-0.3.0 serf
chown -R 1000:users neon serf
./configure \
--prefix=/usr/local/subversion \
--with-apxs=/usr/local/apache2/bin/apxs \
--with-ssl \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-zlib=/usr/lib64 \
--with-swig=/usr/local/swig/bin/swig \
--enable-shared \
--enable-static \
PYTHON=/usr/local/python2/bin/python
make && make install
5、配置SVN
參見我之前的博文 http://www.linuxidc.com/Linux/2014-01/95226.htm 。
6、綁定subversion
1234 cd subversion-1.6.18
make swig-py
make check-swig-py #有一個trac的報錯,無須理會
make install-swig-py
7、添加svn的python binding安裝路徑到Python的path中
由於是源碼安裝,svn的python-binging 不在python默認的搜索路徑中,默認是/usr/local/lib/svn-python/,需要修改如下:
cd /usr/local/python2/lib/python2.7/site-packages
echo /usr/local/subversion/lib/svn-python > subversion.pth
echo /usr/local/subversion/lib >> /etc/ld.so.conf
ldconfig
8、測試svn模塊
首先要修改python的可執行文件路徑,這是由於系統自帶的python未刪除。如果不修改,viewvc在調用python的時候默認使用系統自帶的。如果你不嫌麻煩,那麼請修改viewvc-1.1.21安裝目錄下的所有腳本文件,它們的路徑都是以#!/usr/bin/python開頭的。
cd /usr/bin
mv python python.bak
ln -s /usr/local/python2/bin/python python
執行如下命令測試:
# python
Python 2.7.6 (default, Nov 29 2013, 11:32:29)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
Type "help", "right", "credits" or "license" for more information.
>>> import svn.core
❷ 如何在linux上安裝svn伺服器
你好,centos下安裝 svn 1.9.5 按照步驟一步一步裝就OK 。以下是我的步驟。分享給你
安裝1.9
准備工作:
1、安裝編譯工具包
yum install apr* autoconf automake bison bzip2 cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng* libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* libX* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils ppl telnet t1lib t1lib* nasm nasm* wget zlib-devel zlib unzip perl-ExtUtils-Embed
2、yum remove apr apr-util subversion subversion-libs #刪除系統中原有的svn及依賴包
3、下載軟體包
https://dist.apache.org/repos/dist/release/apr/apr-1.5.2.tar.gz
https://dist.apache.org/repos/dist/release/apr/apr-util-1.5.4.tar.gz
http://prdownloads.sourceforge.net/scons/scons-2.3.5.tar.gz
http://www.openssl.org/source/openssl-1.0.1o.tar.gz
https://www.apache.org/dist/serf/serf-1.3.9.tar.bz2
http://www.apache.org/dist/subversion/subversion-1.8.13.tar.gz
http://www.sqlite.org/2017/sqlite-amalgamation-3160200.zip
1、安裝apr
cd /usr/local/src #進入軟體包存放目錄
tar zxvf apr-1.5.2.tar.gz #解壓
cd apr-1.5.2 #進入安裝目錄
./configure --prefix=/usr/local/apr #配置
make #編譯
make install #安裝
2、安裝apr-util
cd /usr/local/src
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
3、安裝scons
cd /usr/local/src
tar zxvf scons-2.3.5.tar.gz
cd scons-2.3.5
python setup.py install #配置安裝
4、安裝openssl
cd /usr/local/src
tar zxvf openssl-1.0.1o.tar.gz
cd openssl-1.0.1o
CFLAGS=-fPIC ./config --prefix=/usr/local/openssl enable-shared
make && make install
vi /etc/profile #添加系統環境變數
export PATH=$PATH:/usr/local/openssl/bin >> /etc/profile
#export PATH=$PATH:/usr/local/openssl/bin >> /etc/profile
:wq! #保存退出
source /etc/profile #使配置生效
ln -s /usr/local/openssl/include/openssl /usr/include/openssl #添加系統軟連接
5、安裝serf
cd /usr/local/src
tar -xf serf-1.3.9.tar.bz2
cd serf-1.3.9
scons PREFIX=/usr/local/serf APR=/usr/local/apr/bin/apr-1-config APU=/usr/local/apr/bin/apu-1-config OPENSSL=/usr/local/openssl
scons install
cd /usr/local/serf/lib
cp libserf-1.so* /usr/local/lib/ #拷貝文件到系統目錄
6、安裝svn
cd /usr/local/src
tar zxvf subversion-1.9.5.tar.gz
cd subversion-1.9.5
mkdir /usr/local/src/subversion-1.9.5/sqlite-amalgamation #創建sqlite-amalgamation目錄
cd /usr/local/src
unzip sqlite-amalgamation-3160200.zip -d /usr/local/src/subversion-1.9.5/sqlite-amalgamation
mv /usr/local/src/subversion-1.9.5/sqlite-amalgamation/sqlite-amalgamation-3160200/* /usr/local/src/subversion-1.9.5/sqlite-amalgamation
#解壓sqlite-amalgamation軟體包到sqlite-amalgamation目錄
cd /usr/local/src/subversion-1.9.5
./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-serf=/usr/local/serf --with-openssl=/usr/local/openssl --enable-mod-activation #配置
make #編譯
make install #安裝
vi /etc/profile #添加系統環境變數,添加到最後一行
export PATH=$PATH:/usr/local/svn/bin
:wq! #保存退出
source /etc/profile #使配置立刻生效
whereis libexpat.so.1 #查找文件安裝目錄,如下:
libexpat.so: /lib/libexpat.so.0 /usr/local/lib/libexpat.so /usr/local/lib/libexpat.so.1
vi /etc/ld.so.conf #編輯加入libexpat.so.1的目錄
/usr/local/lib/
:wq! #保存退出
ldconfig #使配置生效
❸ linux 下 socket編程的一個小問題 代碼貼出來了 程序編譯完全沒有問題 就是伺服器出不了結果 是recv問題
問題:
1:accept最後的參數出錯;
2:編程規范嚴重不足
3:出錯異常沒有檢測,以致問題很難發現
還要注意printf函數說明,這是帶緩沖行列印介面,字元串最後最好帶回車;
這是我修改過的,請參考,我自己驗證通過
//server
intmain()
{
//創建套介面
intserfd,clifd;
serfd=socket(AF_INET,SOCK_STREAM,0);
structsockaddr_inseraddr,cliaddr;
intaddrlen=sizeof(cliaddr);
charbuffer[200];
//創建地址
bzero(&seraddr,sizeof(seraddr));
seraddr.sin_family=AF_INET;
seraddr.sin_port=htons(6000);
seraddr.sin_addr.s_addr=htonl(INADDR_ANY);
//綁定
if(bind(serfd,(structsockaddr*)&seraddr,sizeof(seraddr))<0)
{
perror("bind");
return-1;
}
//jianting
if(listen(serfd,5)<0)
{
perror("listen");
return-1;
}
printf("serislistening ");
//
clifd=accept(serfd,(structsockaddr*)&cliaddr,(socklen_t*)&addrlen);//最後一參數出錯
if(clifd<0)
{
perror("accept");
return-1;
}
intrecvLen=0;
while(1)
{
memset(buffer,0,sizeof(buffer));
if((recvLen=recv(clifd,buffer,sizeof(buffer),0))>0)
{
printf("clientsend:%s ",buffer);
}
elseif(recvLen==0)
{
perror("clientclosed");
return-1;
}
else
{
perror("recv");
return-1;
}
}
return0;
}
//client
intmain(intargc,char*argv[])
{
//
intclifd=socket(AF_INET,SOCK_STREAM,0);
structsockaddr_inseraddr;
charsendbuf[200];
intsendLen;
seraddr.sin_family=AF_INET;
seraddr.sin_port=htons(6000);
seraddr.sin_addr.s_addr=inet_addr("127.0.0.1");
if(connect(clifd,(structsockaddr*)&seraddr,sizeof(seraddr))==0)
printf("linkingsuccess! ");
while(1)
{
scanf("%s",sendbuf);
if(strcmp(sendbuf,"x")==0)
break;
if((sendLen=send(clifd,sendbuf,sizeof(sendbuf),0))<0)
{
perror("senderror!");
return-1;
}
elseif(sendLen==0)
{
perror("serverclosed!");
return0;
}
printf("senddata:%s ",sendbuf);
}
close(clifd);
return0;
}