主要安装步骤参考:
Mac上安装svn+http访问(编译subversion,serf,apr,apr-util,httpd)_ellende的博客-CSDN博客_mac serf
但是在安装中遇到一些问题,这里做个记录
------------------------------------------------------------------------------------------------------------------------------------
前提工具安装
Mac 不同版本自带的环境有些差异,下面的三个是都会用到的,所以开始之前不管有没有,先执行一下
brew install libtool
brew install openssl
brew install scons
autoconf zlib
curl -O http://mirrors.kernel.org/gnu/m4/m4-1.4.13.tar.gz
tar -xzvf m4-1.4.13.tar.gz
cd m4-1.4.13
./configure --prefix=/usr/local
make
sudo make install
cd ..
curl -O http://mirrors.kernel.org/gnu/autoconf/autoconf-2.65.tar.gz
tar -xzvf autoconf-2.65.tar.gz
cd autoconf-2.65
./configure --prefix=/usr/local
make
sudo make install
cd ..
# here you might want to restart your terminal session, to ensure the new autoconf is picked up and used in the rest of the script
curl -O http://mirrors.kernel.org/gnu/automake/automake-1.11.tar.gz
tar xzvf automake-1.11.tar.gz
cd automake-1.11
./configure --prefix=/usr/local
make
sudo make install
cd ..
curl -O http://mirrors.kernel.org/gnu/libtool/libtool-2.2.6b.tar.gz
tar xzvf libtool-2.2.6b.tar.gz
cd libtool-2.2.6b
./configure --prefix=/usr/local
make
sudo make install
curl -O http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
Mac OS 10.14.1 还需要单独安装pcre (注意是pcre. 不要安装成了pcre2)
tar -zxf pcre-8.42.tar.gz
cd pcre-8.42
./configure
make && make install
Mac OS 中安装 autoconf 和 automake - 灰色飘零 - 博客园
Mac 编译安装zlib_sunStd的博客-CSDN博客_mac zlib
-------------------------------------------------------------------------------------------------------------------------------
安装 apr apr-tools
安装apr 遇到的第一个问题 cannot remove `libtoolT': No such file or directory ( Mac OS 10.15.7会遇到,10.14.4 貌似没有遇到 )
解决方案:在configure里面 RM='$RM'
把RM='$RM'改为RM='$RM -f'
注意,此文件下载到本地修改在上传会报错。建议用VI修改
Linux安装apache时 apr报错解决 rm: cannot remove `libtoolT': No such file or directory_天才少年程序员-李荣盛专栏-CSDN博客
安装 apr 遇到的第二个问题 Can not determine the proper size for pid_t ( Mac OS 10.15.7会遇到,10.14.4 貌似没有遇到 )
解决方案 修改文件arp_want头文件
步骤一:路径:/apr-1.7.0/include/apr_want.h
改法:用/* */注释掉结构体iovec的定义
步骤二:修改apr.h文件
路径:httpd-2.4.46/srclib/apr/include/apr.h
改法:
找到"#error Can not determine the proper size for pid_t"
将其替换成:#define APR_PID_T_FMT "d"
参考文档:在macOS(Big Sur- 11.2.2)上通过源码安装apache httpd(2.4.46)_vickqi的专栏-CSDN博客
若没有自动下载apr和apr-util包,可以用下面链接:
http://archive.apache.org/dist/apr/ 选择apr和apr-util包下载
接下来配置安装apr包:
cd apr
./configure --prefix=/usr/local/opt/apr-svn
make clean
make && make install
cd ..
再配置安装apr-util包:
cd apr-util
./configure --prefix=/usr/local/opt/apr-util-svn --with-apr=/usr/local/opt/apr-svn
make clean
make && make install
cd ..
----------------------------------------------
安装 serf
curl -O http://archive.apache.org/dist/serf/serf-1.3.9.tar.bz2
tar -jxvf serf-1.3.9.tar.bz2
cd serf-1.3.9
遇到两个问题
若要svn支持http访问,需要安装serf。
http://archive.apache.org/dist/serf/ 选择serf-1.3.9.tar
openssl用brew install openssl安装即可,scons用brew install scons安装即可。
配置编译serf:
cd serf-1.3.9
下面两个命令,注意OpenSsl的位置
scons APR=/usr/local/opt/apr-svn PREFIX=/usr/local/opt/serf-1.3.9 APU=/usr/local/opt/apr-util-svn OPENSSL=/usr/local/Cellar/openssl/1.0.2l/
scons APR=/usr/local/opt/apr-svn PREFIX=/usr/local/opt/serf-1.3.9 APU=/usr/local/opt/apr-util-svn OPENSSL=/usr/local/opt/openssl@1.1
安装serf:
sudo scons install
问题一:print 'Warning: Used unknown variables:', ', '.join(unknown.keys())
解决方案: 修改 serf-1.3.9/SConstruct ,186行,注释掉 打印语句(185行,186行)
问题二:cannot use a string pattern on a bytes-like object
解决方案:修改 serf-1.3.9/SConstruct ,169行,
env.File('serf.h').get_contents(), // 将这个改成下面这个,加上 decode('utf-8')
env.File('serf.h').get_contents().decode('utf-8'),
参考资料:
2. CentOS7.2源码安装Subversion1.9.7【填坑记】_China_Style的专栏-CSDN博客_scons serf
在编译 Httpd 时遇到错误,错误描述
mod_ext_filter.c:372:10: error: implicit declaration of function 'apr_procattr_limit_set' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
rv = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu);
^
1 error generated.
解决方案:在/httpd-2.4.33/modules/filters/mod_ext_filter.c 的36 行后面添加下面代码
APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr,
apr_int32_t what,
struct rlimit *limit);
在编译 Httpd 时,还遇到了权限问题
解决方案: sudo make && sudo make install
Httpd 编译好之后,编译subversion需要额外加参数。(--with-lz4=internal --with-utf8proc=internal)
配置subversion:
cd subversion
./configure --prefix=/usr/local/opt/svn --with-apr=/usr/local/opt/apr-svn --with-apr-util=/usr/local/opt/apr-util-svn --with-apxs=/usr/local/apache2/bin/apxs --with-serf=/usr/local/opt/serf-1.3.9 --with-lz4=internal --with-utf8proc=internal
------------------------------------------------------------------------------------------------------
安装好后,可能还应为 logs 目录的权限导致服务启动失败
httpd not running, trying to start
(13)Permission denied: AH00091: httpd: could not open error log file /usr/local/apache2/logs/error_log.
AH00015: Unable to open logs
解决方法:设置目录权限
sudo chmod -R 777 /usr/local/apache2/
// 下面这个是 SVN 仓库地址的权限
sudo chown -R root:admin Users/rain/svnServer/xxRepository
安装好环境之后,可参考创建SVN仓库和账号等配置
配置SVN的HTTP访问的方式_胡振伟博客-CSDN博客_svn网页访问
另外附上 htpasswd 命令常用
# 密码文件创建(注意,-c 命令如果文件不存在则会创建文件,如果文件已经存在了,会覆盖,原有的内容会消失)
htpasswd -c /Users/rain/svnServer/xxRepository/conf/passwd userName
# 添加账户密码
htpasswd -b /Users/rain/svnServer/xxRepository/conf/passwd userName userPwd123456
# 更新密码(只能先删除,后添加)
htpasswd -D /Users/rain/svnServer/xxRepository/conf/passwd userName
htpasswd -b /Users/rain/svnServer/xxRepository/conf/passwd userName userPwd123456
## 最后附上开机启动陪着
自动启动配置文件(需要自己创建)
/Library/LaunchDaemons/org.apache.httpdSvn.plist
// 创建文件
sudo touch /Library/LaunchDaemons/org.apache.httpdSvn.plist
sudo vim /Library/LaunchDaemons/org.apache.httpdSvn.plist
自动启动配置文件内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.apache.httpdSvn</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/apache2/bin/apachectl</string>
</array>
<key>StandardErrorPath</key>
<string>/Users/XXXXX/Desktop/APP/Logs/SvnService/error</string>
</dict>
</plist>