设为首页 收藏本站
查看: 785|回复: 1

[经验分享] How to Setup Apache Subversion with HTTPS CentOs7-Arnold

[复制链接]
YunVN网友  发表于 2019-4-18 12:03:31 |阅读模式
  Apache Subversion or SVN is open source versioning and revision control software developed by the Apache Software Foundation. It is used to maintain the current and historical versions of source code, documents, and Web pages.
  Subversion is used by many software developers and open source projects like Apache Software Foundation, FreeBSD, GCC and SourceForge.
  In this article, we show you how to set up Apache Subversion on the latest CentOS 7 server. We install and configure the svn software with Apache as web server, secure it with Let's encrypt and activate "Basic Authentication" for users.
Prerequisites

  •   CentOS 7 Server
  •   Root privileges
What we will do

  •   Install Apache Httpd on CentOS 7
  •   Install Subversion
  •   Configure the Subversion Repository
  •   Generate SSL Letsencrypt for CentOS Apache Httpd
  •   Configure Subversion Virtual Host on Apache Httpd
  •   Testing
Step 1 - Install Apache Httpd on CentOS 7
  The first step in this guide is to install the Apache httpd packages on your system.
  Install Apache httpd using the yum command below.
  yum -y install httpd httpd-tools mod_ssl
  And after the installation is complete, we need to add the HTTP service to the firewalld service lists.
  Run firewall-cmd commands below.
  firewall-cmd --permanent --zone=public --add-service=http
  firewall-cmd --reload
  Now start the httpd service and add it to be started at boot.
  systemctl start httpd
  systemctl enable httpd
  The Apache httpd is up and running on the server.

Step 2 - Install Apache Subversion (SVN)
  In this tutorial, we will install the subversion packages from the base CentOS 7 repository.
  Install Subversion and all required packages using the yum command below.
  yum -y install subversion subversion-tools mod_dav_svn
  Wait until all packages are installed and then check the svn version.
  svn --version

Step 3 - Configure the Subversion (SVN) Repository
  After the Subversion installation, we configure the master subversion repository directory. We will create a new 'svn' directory where all source code and repositories will be stored.
  Create a new '/svn' master directory.
  mkdir /svn
  And create a new sample repository named 'hakase-project' using the svnadmin command below.
  svnadmin create /svn/hakase-project
  Now change the owner of the '/svn/hakase-project' directory to the 'apache' user and group.
  sudo chown -R apache:apache /svn/hakase-project
  And the svn repository has been created.

  Note:
  Additional for SELinux users, run commands below.
  chcon -R -t httpd_sys_content_t /svn/hakase-project
  chcon -R -t httpd_sys_rw_content_t /svn/hakase-project
Step 4 - Generate Let's encrypt SSL Certificate for Apache
  In this tutorial, we configure the svn server to use the HTTPS connection with a domain named 'svn.hakase-labs.io'. We will use a free Let's encrypt SSL certificate which can be generated with the certbot tool.
  Install certbot on the CentOS server with the yum command below.
  yum -y install certbot
  When the installation is complete, we need to add the HTTPS service to the firewalld services list.
  Run firewalld commands below.
  firewall-cmd --add-service=https --zone=public --permanent
  firewall-cmd --reload
  Now stop the httpd service, so we can generate the SSL Letsencrypt using the 'standalone' temporary web server.
  systemctl stop httpd

  Generate the Letsencrypt SSL Cert for the domain name 'svn.hakase-labs.io' using the certbot command below.
  certbot certonly --rsa-key-size 4096 --standalone --agree-tos --no-eff-email --email hakase@gmail.com -d svn.hakase-labs.io
  Now you will get the certificate files on the '/etc/letsencrypt/live' directory.

Step 5 - Configure Subversion Virtual Host on Apache Httpd
  In this step, we will create a new Apache httpd configuration for the svn access. We will configure the svn repository using a domain name 'svn.hakase-labs.io', and it will be accessible only for the registered users using the HTTP basic auth.
  Go to the '/etc/httpd/conf.d' directory and create a new svn configuration 'svn.conf'.
  cd /etc/httpd/conf.d/
  vim svn.conf
  Paste configurations below.
  

  
ServerName svn.hakase-labs.io
  
DocumentRoot /var/www/html
  
Redirect permanent / https://svn.hakase-labs.io
  

  

  

  

  

  
DocumentRoot /var/www/html
  
ServerName svn.hakase-labs.io
  

  
SSLEngine on
  
SSLProtocol all -SSLv2
  
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
  
SSLCertificateFile /etc/letsencrypt/live/svn.hakase-labs.io/fullchain.pem
  
SSLCertificateKeyFile /etc/letsencrypt/live/svn.hakase-labs.io/privkey.pem
  

  
ErrorLog logs/svn_error_log
  
TransferLog logs/svn_access_log
  
LogLevel warn
  

  

  
DAV svn
  
SVNParentPath /svn/
  
AuthType Basic
  
AuthName "Authorization Realm"
  
AuthUserFile /etc/subversion/svn.users
  
Require valid-user
  

  

  

  
    SSLOptions +StdEnvVars
  

  

  
SetEnvIf User-Agent ".*MSIE.*" \
  
         nokeepalive ssl-unclean-shutdown \
  
         downgrade-1.0 force-response-1.0
  
CustomLog logs/ssl_request_log \
  
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
  

  Save the file and exit the editor.
  Next, we need to create a new list of users that will be able to view and commit files to the repository.
  Create a new user named 'hakase' using the htpasswd command below.
  sudo htpasswd -cm /etc/subversion/svn.users hakase
  Now restart the Apache httpd services.
  systemctl restart httpd
  The 'hakase' user now has an access to view and commit the source code to the 'hakase-project' repository.

Step 6 - Testing
Viewing Repository
  Open your web browser and type the server URL, mine is this one: https://svn.hakase-labs.io/repo/hakase-project/
  And you will be shown the basic user authentication prompt.

  Login with the 'hakase' user and password, and following is the result.

Import a Project to the Repository
  Now we will import the svn sample project templates to the 'hakase-project' repository.
  Create a new svn-templates project directory.
  mkdir -p ~/svn-templates/{trunk,branches,tags}
  Add all templates directory to the 'hakase-project' repository using the svn command below.
  svn import -m 'Initial import' ~/svn-templates/ https://svn.hakase-labs.io/repo/hakase-project/ --username hakase
  Now you will be asked following things.

  •   Type 'p' to add permanently the Letsencrypt certificate.
  •   Type the 'hakase' user and password.
  •   And type 'yes' to confirm about the saving unencrypted password.

  Check the 'hakase-project' from the web browser, and you will get all the templates directory on it.

Clone the Repository
  After creating and upload the svn templates directory, we want to clone or copy the repository to the local environment.
  Create a new normal user and login to the user.
  useradd -m -s /bin/bash misaka
  su - misaka
  Clone the 'hakase-project' repository the local directory named 'myproject' as a 'hakase' user.
  svn co https://svn.hakase-labs.io/repo/hakase-project/ ~/myproject --username hakase
  And you will be asked again about those things below.

  •   Type 'p' to add permanently the Letsencrypt certificate.
  •   Type the 'hakase' user and password.
  •   And type 'yes' to confirm about the saving unencrypted password.

  And when it's complete, check the new 'myproject' directory and you will get all svn templates.
  tree ~/myproject

Commit The Code or Documents
  Go to the 'myproject' directory.
  cd myproject/
  Create some files on the 'trunk' directory.
  echo 'this is my repo' > trunk/test-hakase.txt
  echo 'this is my repo01' > trunk/test-hakase01.txt
  echo 'this is my repo02' > trunk/test-hakase02.txt
  Add and commit.
  svn add trunk/* --username hakase
  svn commit -m 'new file added' --username hakase

  Check the repository from the web browser, and you will see all files have been added to the repository.

  The Apache Subversion installation and configuration with HTTPS Letsencrypt on CentOS 7 has been completed successfully.
Reference

  •   https://subversion.apache.org/



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-828497-1-1.html 上篇帖子: 虚拟机及CentOS 安装 下篇帖子: Centos7编辑安装mysql(mysql
累计签到:1 天
连续签到:1 天
发表于 2019-4-18 13:15:18 | 显示全部楼层
多谢分享,厉害的

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表