Raspbian Apache2 メモ

git clone https://bitbucket.org/sol_prog/raspberry-pi-gcc-binary.git

cd raspberry-pi-gcc-binary
tar xf gcc-8.1.0.tar.bz2
sudo mv gcc-8.1.0 /usr/local

export PATH=/usr/local/gcc-8.1.0/bin:$PATH
echo 'export PATH=/usr/local/gcc-8.1.0/bin:$PATH' >> .bashrc
source .bashrc

gcc-8.1.0 --version

sudo rm gcc g++
sudo ln -s /usr/local/gcc-8.1.0/bin/g++-8.1.0 g++
sudo ln -s /usr/local/gcc-8.1.0/bin/gcc-8.1.0 gcc


sudo gem install passenger

sudo apt-get -y install libcurl4-openssl-dev
sudo apt-get -y install apache2-dev
sudo apt-get -y install libapr1-dev
sudo apt-get -y install libaprutil1-dev
sudo apt-get -y install ruby-dev

sudo passenger-install-apache2-module
sudo vim /etc/apache2/apache2.conf
<pre>

LoadModule passenger_module /var/lib/gems/2.5.0/gems/passenger-5.3.4/buildout/apache2/mod_passenger.so
\<IfModule mod_passenger.c>
  PassengerRoot /var/lib/gems/2.5.0/gems/passenger-5.3.4
  PassengerDefaultRuby /usr/bin/ruby2.5
\</IfModule>

</pre>

sudo vim /etc/gitlab/gitlab.rb

<pre>
 external_url 'http://raspberrypi/gitlab'
 ...
 gitlab_rails['time_zone'] = 'Asia/Tokyo'
 ...
 nginx['enable'] = false
 ...
 web_server['external_users'] = ['www-data']
 ...
 gitlab_rails['trusted_proxies'] = [ '192.168.1.0/24', '192.168.30.0/24', '2001:0db8::/32' ]
 ...
 gitlab_workhorse['listen_network'] = "tcp"
 gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
</pre>

sudo gitlab-ctl reconfigure

sudo wget -P /etc/apache2/sites-available/gitlab.conf https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/web-server/apache/gitlab-omnibus-apache24.conf?inline=false

sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http

sudo vim /etc/apache2/sites-available/gitlab.conf
<pre>
\<VirtualHost *:80>
  ServerName 192.168.x.x # 書き換え
  ServerSignature Off

  ProxyPreserveHost On

  AllowEncodedSlashes NoDecode

  Alias /gitlab /opt/gitlab/embedded/service/gitlab-rails/public # 追加

  \<Location /gitlab> # 書き換え
    PassengerBaseURI /gitlab # 追加
    PassengerAppRoot /opt/gitlab/embedded/service/gitlab-rails # 追加

    Require all granted

    ProxyPassReverse http://127.0.0.1:8181
    ProxyPassReverse http://192.168.x.x/gitlab # 書き換え

 # \</Location> # Location をここで閉じない

    RewriteEngine on

    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_URI} ^/uploads/.*
    RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]

  \</Location> # Location の範囲をここまで広げる

  # DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public # コメントアウトまたは削除する

  ErrorDocument 404 /gitlab/404.html # 書き換え
  ErrorDocument 422 /gitlab/422.html # 書き換え
  ErrorDocument 500 /gitlab/500.html # 書き換え
  ErrorDocument 502 /gitlab/502.html # 書き換え
  ErrorDocument 503 /gitlab/503.html # 書き換え

  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
  ErrorLog /var/log/apache2/gitlab_error.log # 書き換え
  CustomLog /var/log/apache2/gitlab_forwarded.log common_forwarded # 書き換え
  CustomLog /var/log/apache2/gitlab_access.log combined env=!dontlog # 書き換え
  CustomLog /var/log/apache2/gitlab.log combined # 書き換え

\</VirtualHost>

</pre>

sudo a2ensite gitlab
sudo chmod 711 /opt/gitlab/embedded/service/gitlab-rails/public/uploads/