CentOS8ã«Subversion1.14+httpdãã¤ã³ã¹ãã¼ã«ãã¦nginxã§ãªãã¼ã¹ãããã·ãã
CentOS Stream 8 + Nginxã§éç¨ãã¦ããç°å¢ã«Subversion + Apache HTTP Serverãã¤ã³ã¹ãã¼ã«ãã¦、æ§ãµã¼ãã¼ãããªãã¸ããªãç§»è¡ããã¨ãã®è¦æ¸。
ç°å¢: CentOS Stream 8, nginx 1.22.1, httpd 2.4.37, subversion 1.14.1
ï¼. Subversionãã¤ã³ã¹ãã¼ã«
dnf(yum)çµç±ã§ã¤ã³ã¹ãã¼ã«ãããã¨ã«ãã。
# dnf module list subversion
# dnf module install subversion:1.14
Apache HTTPãµã¼ãã¼çµç±ã§subversionãªãã¸ããªã«ã¢ã¯ã»ã¹ããã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«
# dnf install httpd mod_dav_svn
/etc/httpd/modules/ã«é ç½®ãã、/etc/httpd/conf.modules.d/10-subversion.confã§èªåã§èªã¿è¾¼ã¾ãã。
ï¼.httpdã®è¨å®。nginxãããããã·ãã。
httpdã¯ãã¼ã8080ã§åãã。å¤ããã®ãã¼ãã¯éããªã。
# less /etc/httpd/conf/httpd.conf
Listen 8080User apacheGroup www
ServerAdmin [email protected]
èµ·å、èªåèµ·åON、確èª
# apachectl configtest
# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd
# systemctl list-unit-files -t service
ã¤ã³ã¹ãã¼ã«æã«çæãããconfã¯å¥ãã£ã¬ã¯ããªã¸
# cd /etc/httpd/conf.d/
# mkdir bak
# mv *.conf bak/
Subversionç¨ãªãã¸ããªã®ç½®ãå ´æã使
# mkdir /home/svn
# mkdir /home/svn/repo
svnç¨httpdè¨å®ãã¡ã¤ã«ã使
# vi 01_svn.conf
<VirtualHost *:8080>ServerName svn.hoge.co.jp<Location />DAV svnSVNParentPath /home/svn/repoSVNListParentPath on</Location></VirtualHost>
httpdåèªã¿è¾¼ã¿
# apachectl configtest
# systemctl reload httpd
nginxã«ãªãã¼ã¹ãããã·ã®è¨å®
# cd /etc/nginx/conf.d/
# less 02_svn.conf
server {listen 80;server_name svn.*;client_max_body_size 300M;location / {proxy_set_header Host $http_host;proxy_set_header Destination $http_destination;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_pass http://127.0.0.1:8080;}}
nginxåèªã¿è¾¼ã¿
# nginx -t
# systemctl reload nginx
åä½ãã¹ã
# cd /home/svn/repo/
# svnadmin create test
# chown -R apache.www test/
TortoiseSVNã§ãã§ãã¯ã¢ã¦ããã¦ç¢ºèª。
ï¼.Httpså
nginxã¾ã§ãTLSã§æå·åãã。
certbotç¨ã®è¨å®ã追è¨ãã。
# cd /etc/nginx/conf.d/
# less 02_svn.conf
server {listen 80;server_name svn.*;client_max_body_size 300M;# Accept for Let's Encrypt(certbot)location /.well-known/acme-challenge {access_log off;root /var/www/html/;}location / {proxy_set_header Host $http_host;proxy_set_header Destination $http_destination;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_pass http://127.0.0.1:8080;}}
nginxåèªã¿è¾¼ã¿
# nginx -t
# systemctl reload nginx
certbotã§SSLè¨¼ææ¸åå¾
# certbot certonly --webroot -w /var/www/html/ -d svn.hoge.co.jp
nginxè¨å®ãã¡ã¤ã«ç·¨é
# less 02_svn.conf
server {listen 80;server_name svn.*;return 301 https://svn.hoge.co.jp$request_uri;}server {listen 443 ssl;server_name svn01.*;# Accept for Let's Encrypt(certbot)location /.well-known/acme-challenge {access_log off;root /var/www/html/;}# Fixed for move japanese file in svnset $fixed_destination $http_destination;if ( $fixed_destination ~ ^https(?<myurl>.*)$ ) {set $fixed_destination "http$myurl";}location / {client_max_body_size 300M;access_log off;error_log /dev/null;proxy_set_header Host $http_host;proxy_set_header Destination $http_destination;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_pass http://127.0.0.1:8080;}include conf.d/global/ssl.conf;ssl_certificate /etc/letsencrypt/live/svn.hoge.co.jp/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/svn.hoge.co.jp/privkey.pem;ssl_trusted_certificate /etc/letsencrypt/live/svn.hoge.co.jp/chain.pem;}
æ¥æ¬èªãã¡ã¤ã«åãåå夿´ãããç§»åããã¨ãã®ã¨ã©ã¼ã«å¯¾å¿。
åè: Nginx(HTTPS)ã§Subversion(HTTP/Apache)ããªãã¼ã¹ãããã·ããå ´åã«æ¥æ¬èªãã¡ã¤ã«åã®moveã失æããã¨ããã 【Nginxã®2éURLã¨ã³ã³ã¼ãã£ã³ã°】 - Qiita
access_logã¨error_logã¯httpdã®æ¹ã§è¨é²ããã®ã§ãããªãã¨æã。
nginxåèªã¿è¾¼ã¿
# nginx -t
# systemctl reload nginx
TortoiseSVNã§ãã§ãã¯ã¢ã¦ããã¦ç¢ºèª。
ï¼.ã¢ã¯ã»ã¹å¶å¾¡
åã¯USVNã¨ããã¦ã§ã管çãã¼ã«ã使ã£ã¦ã¿ããã©、USVNã¯éçºãæ¢ã¾ã£ã¦ããã®ã§ã³ãã³ãã©ã¤ã³ã§ç®¡çãã。
åè: Subversionã®ã¦ã§ã管çãã¼ã«USVNãã¤ã³ã¹ãã¼ã«
Basicèªè¨¼ã®ã¦ã¼ã¶ã¼ã使ãã。
# cd /home/svn/
# htpasswd -c .htpasswd daiki
Subversionã®ã¢ã¯ã»ã¹å¶å¾¡ãã¡ã¤ã«ã使。
ãã¡ã¤ã«åã«.htãä»ãã¦ããã®ã¯httpd.confã§ã¢ã¯ã»ã¹æå¦è¨å®ã«ãªã£ã¦ãããã。
# vi .htauthz
[groups]admin = daiki[/]* =@admin = rw
ããã©ã«ãã¯å
¨å¡èªã¿æ¸ãä¸å¯。
adminã°ã«ã¼ãã ãèªã¿æ¸ãå¯è½ã«ãã¦ãã。
httpdè¨å®ãã¡ã¤ã«ç·¨é。
# cd /etc/httpd/conf.d/
# less 01_svn.conf
<VirtualHost *:8080>ServerName svn.hoge.co.jpRequestHeader edit Destination ^https http earlyTimeout 600<Location />DAV svnSVNParentPath /home/svn/repoSVNListParentPath onSVNAdvertiseV2Protocol offRequire valid-userAuthType BasicAuthName "SVN"AuthUserFile /home/svn/.htpasswdAuthzSVNAccessFile /home/svn/.htauthz</Location></VirtualHost>
httpdåèªã¿è¾¼ã¿
# apachectl configtest
# systemctl reload httpd
TortoiseSVNã§Update/Commitãã¦ç¢ºèª。
ï¼.IPã¢ãã¬ã¹å¶é
念ã®ããæ¥æ¬ããã®IPã¢ãã¬ã¹ãã許å¯ããªãããã«ãã。
å½å¥ã®IPã¢ãã¬ã¹ä¸è¦§åå¾ã¯åã®è¨äºãåèã«。
åè: GeoIP2ã®CSVãã¼ã¿ã§PostgresSQLãã¼ã¿ãã¼ã¹ãæ´æ°ãã¦å½å¥æå¦ãªã¹ããçæ
nginxè¨å®ç¨ã®è¨±å¯ä¸è¦§ãçæãã。
# su - postgres
$ psql geo -c "SELECT concat('allow ', network, ';') FROM geoip2_network gn LEFT JOIN geoip2_location gl on gn.geoname_id = gl.geoname_id WHERE gl.country_iso_code = 'JP';" >> allow_JP.conf
å
é ã¨æ«å°¾ã®ãããªãè¡ãåé¤ãã。
viã³ãã³ãã¯「1G」ã§å
é ã«、「G」ã§ãã¡ã¤ã«æ«å°¾ã«ç§»åã§ãã。
「dd」ã§è¡åé¤。
# less allow_JP.conf
ããããµã¼ãã¼ã«è¨ç½®ãã¦nginxè¨å®ãã¡ã¤ã«ãç·¨é。
# cd /etc/nginx/conf.d/
# less 02_svn.conf
# Restrict access from Japaninclude conf.d/global/allow_JP.conf;deny all;
nginxåèªã¿è¾¼ã¿
# nginx -t
# systemctl reload nginx
ï¼.ãªãã¸ããªãç§»è¡
ãã£ã¬ã¯ããªãã¾ããã¨ã³ãã¼ãã¦è»¢é。
# tar -czvf svn_20230101.tgz svn/
Subversionã®ãã¼ã¸ã§ã³ãä¸ãã£ã¦ããã®ã§upgradeãã。
# cd /home/svn/repo/
# svnadmin upgrade project/
TortoiseSVNã§Relocate...ãã¦ç¢ºèª。
ãã£ã¬ã¯ããªãã¨ã«svnadmin upgradeããã®ãé¢åãããã®ã§bashã¹ã¯ãªããæ¸ãã。
# vi svnadmin_upgrade.sh
#!/bin/bashdirs="/home/svn/repo/*"for dirpath in $dirs; doif [ -d $dirpath ] ; thenecho "----------"echo "# svnadmin upgrade $dirpath"svnadmin upgrade $dirpathfidone
# chmod +x svnadmin_upgrade.sh
# ./svnadmin_upgrade.sh
æ°è¦ããã¸ã§ã¯ãã¯æ¬¡ã®ã³ãã³ãã§ä½æ。
# cd /home/svn/repo/
# svnadmin create hoge_project
# chown apache.www -R hoge_project
【é¢é£è¨äº】
- GeoIP2ã®CSVãã¼ã¿ã§PostgresSQLãã¼ã¿ãã¼ã¹ãæ´æ°ãã¦å½å¥æå¦ãªã¹ããçæ
- CentOS Stream 8 + Nginx + PHP + MariaDB + Postfixã®ç°å¢ãæ§ç¯(2021å¹´ç)
- Subversionã®ã¦ã§ã管çãã¼ã«USVNãã¤ã³ã¹ãã¼ã«
- CentOS7 + Subversion + SSL(certbot)