<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://chenzhang.org/feed.xml" rel="self" type="application/atom+xml" /><link href="https://chenzhang.org/" rel="alternate" type="text/html" /><updated>2026-02-10T04:08:59+00:00</updated><id>https://chenzhang.org/feed.xml</id><title type="html">Chen Zhang</title><subtitle>http://chenzhang.org</subtitle><entry><title type="html">Install Ollama and Test DeepSeek R1 Model on macOS</title><link href="https://chenzhang.org/notes/developer/ollama-macos/" rel="alternate" type="text/html" title="Install Ollama and Test DeepSeek R1 Model on macOS" /><published>2025-02-01T00:00:00+00:00</published><updated>2025-02-01T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/ollama-macos</id><content type="html" xml:base="https://chenzhang.org/notes/developer/ollama-macos/"><![CDATA[<p>This guide documents how to install and manage <a href="https://ollama.com">Ollama</a> on macOS, using <a href="https://deepseek.com">DeepSeek R1</a> as an example.</p>

<p><strong>Tested Environment:</strong> macOS Sequoia (Apple M4/M2)</p>

<h2 id="install-ollama">Install Ollama</h2>

<p>Install Ollama using Homebrew:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew <span class="nb">install </span>ollama
</code></pre></div></div>

<p>Once the installation is complete, verify it by running:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ollama version
</code></pre></div></div>

<h2 id="manage-the-ollama-service-using-homebrew">Manage the Ollama service using Homebrew</h2>

<p>If the ollama command is not recognized, you may need to manually start the service.</p>

<p>Check active Homebrew services:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew services list
</code></pre></div></div>

<p>Start the Ollama service:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew services start ollama
</code></pre></div></div>

<p>Stop the Ollama service:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew services stop ollama
</code></pre></div></div>

<h2 id="ollama-commands">Ollama commands</h2>

<p>Commonly used Ollama commands, using the DeepSeek R1 (7B) model as an example.</p>

<p>Pull the model:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ollama pull deepseek-r1:7b
</code></pre></div></div>

<p>Run the model (automatically pulls if not already downloaded):</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ollama run deepseek-r1:7b
</code></pre></div></div>

<p>Stop the model:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ollama stop deepseek-r1:7b
</code></pre></div></div>

<p>Delete the model:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ollama <span class="nb">rm </span>deepseek-r1:7b
</code></pre></div></div>

<h2 id="references">References</h2>

<p><a href="https://formulae.brew.sh/formula/ollama">Ollama on Homebrew</a></p>

<p><a href="https://ollama.com/search/">Ollama models</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Ollama" /><category term="#macOS" /><summary type="html"><![CDATA[This guide documents how to install and manage Ollama on macOS, using DeepSeek R1 as an example.]]></summary></entry><entry><title type="html">Run Ollama with Open WebUI</title><link href="https://chenzhang.org/notes/developer/ollama-open-webui/" rel="alternate" type="text/html" title="Run Ollama with Open WebUI" /><published>2025-02-01T00:00:00+00:00</published><updated>2025-02-01T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/ollama-open-webui</id><content type="html" xml:base="https://chenzhang.org/notes/developer/ollama-open-webui/"><![CDATA[<p>This guide documents how to run <a href="https://ollama.com">Ollama</a> in Open WebUI(https://github.com/open-webui/open-webui).</p>

<p><strong>Tested Environment:</strong> macOS Sequoia (Apple M4/M2)</p>

<h2 id="install-open-webui-using-docker">Install Open WebUI using Docker</h2>

<p>This is an easier way since I don’t want to mess up my Python environment.</p>

<p>If Ollama is on your computer:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker run <span class="nt">-d</span> <span class="nt">-p</span> 3000:8080 <span class="nt">--add-host</span><span class="o">=</span>host.docker.internal:host-gateway <span class="nt">-v</span> open-webui:/app/backend/data <span class="nt">--name</span> open-webui <span class="nt">--restart</span> always ghcr.io/open-webui/open-webui:main
</code></pre></div></div>

<p>If Ollama is on a Different Server (change the OLLAMA_BASE_URL to the server’s URL):</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker run <span class="nt">-d</span> <span class="nt">-p</span> 3000:8080 <span class="nt">-e</span> <span class="nv">OLLAMA_BASE_URL</span><span class="o">=</span>https://example.com <span class="nt">-v</span> open-webui:/app/backend/data <span class="nt">--name</span> open-webui <span class="nt">--restart</span> always ghcr.io/open-webui/open-webui:main
</code></pre></div></div>

<p>With Nvidia GPU support:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker run <span class="nt">-d</span> <span class="nt">-p</span> 3000:8080 <span class="nt">--gpus</span> all <span class="nt">--add-host</span><span class="o">=</span>host.docker.internal:host-gateway <span class="nt">-v</span> open-webui:/app/backend/data <span class="nt">--name</span> open-webui <span class="nt">--restart</span> always ghcr.io/open-webui/open-webui:cuda
</code></pre></div></div>

<p><strong><em>Make sure to include the “-v open-webui:/app/backend/data” in the command to ensure your database is properly mounted.</em></strong></p>

<h2 id="install-open-webui-with-bundled-ollama">Install Open WebUI with Bundled Ollama</h2>

<p>With Nvidia GPU support:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker run <span class="nt">-d</span> <span class="nt">-p</span> 3000:8080 <span class="nt">--gpus</span><span class="o">=</span>all <span class="nt">-v</span> ollama:/root/.ollama <span class="nt">-v</span> open-webui:/app/backend/data <span class="nt">--name</span> open-webui <span class="nt">--restart</span> always ghcr.io/open-webui/open-webui:ollama
</code></pre></div></div>

<p>For CPU Only:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker run <span class="nt">-d</span> <span class="nt">-p</span> 3000:8080 <span class="nt">-v</span> ollama:/root/.ollama <span class="nt">-v</span> open-webui:/app/backend/data <span class="nt">--name</span> open-webui <span class="nt">--restart</span> always ghcr.io/open-webui/open-webui:ollama
</code></pre></div></div>

<h2 id="references">References</h2>

<p><a href="https://github.com/open-webui/open-webui">Open Web UI</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Ollama" /><category term="#OpenWebUI" /><summary type="html"><![CDATA[This guide documents how to run Ollama in Open WebUI(https://github.com/open-webui/open-webui).]]></summary></entry><entry><title type="html">SSH Cheat Sheets</title><link href="https://chenzhang.org/notes/developer/ssh-cheat-sheets/" rel="alternate" type="text/html" title="SSH Cheat Sheets" /><published>2021-04-29T00:00:00+00:00</published><updated>2021-04-29T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/ssh-cheat-sheets</id><content type="html" xml:base="https://chenzhang.org/notes/developer/ssh-cheat-sheets/"><![CDATA[<h2 id="installation">Installation</h2>

<p>Install SSH server on Ubuntu:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>apt <span class="nb">install </span>openssh-server
</code></pre></div></div>

<h2 id="passwordless-login">Passwordless Login</h2>

<p>Create SSH key on local machine (located at <code class="language-plaintext highlighter-rouge">~/.ssh</code> by default):</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh-keygen <span class="nt">-t</span> rsa <span class="nt">-b</span> 4096
</code></pre></div></div>

<p>Copy public key to server:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh-copy-id username@ip_address
</code></pre></div></div>

<p>Test:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh username@ip_address
</code></pre></div></div>

<h2 id="references">References</h2>

<p><a href="https://linuxize.com/post/how-to-setup-passwordless-ssh-login/">https://linuxize.com/post/how-to-setup-passwordless-ssh-login/</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Linux" /><category term="#SSH" /><summary type="html"><![CDATA[Installation]]></summary></entry><entry><title type="html">SSL Setup for Apache Web Server</title><link href="https://chenzhang.org/notes/developer/ssl-setup-for-apache-web-server/" rel="alternate" type="text/html" title="SSL Setup for Apache Web Server" /><published>2021-03-30T00:00:00+00:00</published><updated>2021-03-30T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/ssl-setup-for-apache-web-server</id><content type="html" xml:base="https://chenzhang.org/notes/developer/ssl-setup-for-apache-web-server/"><![CDATA[<p>A quick note of enabling SSL for Apache Web Server.</p>

<p>Test environment: Ubuntu 20.04 LTS (Focal Fossa) 64-bit</p>

<h2 id="generate-ssl-certificates">Generate SSL Certificates</h2>

<p>Navigate to the target directory, for example <code class="language-plaintext highlighter-rouge">/root/sys/ssl</code>, and generate private key:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>openssl req <span class="nt">-new</span> <span class="nt">-newkey</span> rsa:2048 <span class="nt">-nodes</span> <span class="nt">-out</span> nassgeodata_gmu_edu.crt <span class="nt">-keyout</span> nassgeodata_gmu_edu.key <span class="nt">-subj</span> <span class="s2">"/C=US/ST=Virginia/L=Fairfax/O=George Mason University/OU=CSISS/CN=nassgeodata.gmu.edu"</span>
</code></pre></div></div>

<p>After requested the certificate, for example <code class="language-plaintext highlighter-rouge">/root/sys/ssl/sslcerts/x509CO/nassgeo_csiss_gmu_edu_cert.cer</code>, create symbolic link of the certificate file:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">ln</span> <span class="nt">-s</span> /root/sys/ssl/sslcerts/x509CO/nassgeo_csiss_gmu_edu_cert.cer /root/sys/ssl/nassgeodata_gmu_edu.cer 
</code></pre></div></div>

<h2 id="enable-ssl">Enable SSL</h2>

<h3 id="configure-apache-web-server">Configure Apache Web Server</h3>

<p>Create symbolic link of SSL config file:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">ln</span> <span class="nt">-s</span> /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/000-default-ssl.conf
</code></pre></div></div>

<p>Edit <code class="language-plaintext highlighter-rouge">/etc/apache2/sites-enabled/000-default-ssl.conf</code> and add:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SSLCertificateFile      /root/sys/ssl/nassgeodata_gmu_edu.cer
SSLCertificateKeyFile   /root/sys/ssl/nassgeodata_gmu_edu.key
</code></pre></div></div>

<p>Enable rewrite mod and restart Apache:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>a2enmod ssl
service apache2 restart
</code></pre></div></div>

<h3 id="redirect-http-to-https-optional">Redirect HTTP to HTTPS (Optional)</h3>

<p>Edit <code class="language-plaintext highlighter-rouge">/etc/apache2/sites-enabled/000-default.conf</code> and add:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>RewriteEngine On
RewriteCond %<span class="o">{</span>HTTPS<span class="o">}</span> <span class="o">!=</span>on
RewriteRule ^/?<span class="o">(</span>.<span class="k">*</span><span class="o">)</span> https://%<span class="o">{</span>SERVER_NAME<span class="o">}</span>/<span class="nv">$1</span> <span class="o">[</span>R,L]
</code></pre></div></div>

<p>Enable rewrite mod and restart Apache:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>a2enmod rewrite
service apache2 restart
</code></pre></div></div>

<h2 id="references">References</h2>

<p><a href="https://hallard.me/enable-ssl-for-apache-server-in-5-minutes/">https://hallard.me/enable-ssl-for-apache-server-in-5-minutes/</a></p>

<p><a href="https://www.tecmint.com/redirect-http-to-https-on-apache/">https://www.tecmint.com/redirect-http-to-https-on-apache/</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Apache" /><category term="#OpenSSL" /><summary type="html"><![CDATA[A quick note of enabling SSL for Apache Web Server.]]></summary></entry><entry><title type="html">GDAL Installation</title><link href="https://chenzhang.org/notes/developer/gdal-installation/" rel="alternate" type="text/html" title="GDAL Installation" /><published>2021-03-16T00:00:00+00:00</published><updated>2021-03-16T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/gdal-installation</id><content type="html" xml:base="https://chenzhang.org/notes/developer/gdal-installation/"><![CDATA[<p>The ubuntu offers the GDAL package by default, but the package version is usually old.  This note documents the step of installing the latest version of GDAL on Ubuntu system.</p>

<p>Test environment: Ubuntu 20.04 LTS (Focal Fossa) 64-bit</p>

<h2 id="installation">Installation</h2>

<p>The current version of GDAL package can be checked using <code class="language-plaintext highlighter-rouge">apt-cache policy gdal-bin</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gdal-bin:
  Installed: (none)
  Candidate: 3.0.4+dfsg-1build3
  Version table:
     3.0.4+dfsg-1build3 500
        500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
</code></pre></div></div>

<p>To update the GDAL package to the latest version, we can add the ubuntugis-unstable PPA to system:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>add-apt-repository ppa:ubuntugis/ubuntugis-unstable
<span class="nb">sudo </span>apt update
</code></pre></div></div>

<p>The source list is located at: <code class="language-plaintext highlighter-rouge">/etc/apt/sources.list.d</code>, the candidate of GDAL package should be updated to the latest version:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gdal-bin:
  Installed: (none)
  Candidate: 3.2.1+dfsg-1~focal0
  Version table:
     3.2.1+dfsg-1~focal0 500
        500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu focal/main amd64 Packages
     3.0.4+dfsg-1build3 500
        500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
</code></pre></div></div>

<p>Install the latest GDAL package:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>apt <span class="nb">install </span>gdal-bin
</code></pre></div></div>

<p>Check the version of installed package using <code class="language-plaintext highlighter-rouge">gdalinfo --version</code> and :</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>GDAL 3.2.1, released 2020/12/29
</code></pre></div></div>

<h2 id="references">References</h2>

<p><a href="https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable">https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#GDAL" /><category term="#Ubuntu" /><summary type="html"><![CDATA[The ubuntu offers the GDAL package by default, but the package version is usually old. This note documents the step of installing the latest version of GDAL on Ubuntu system.]]></summary></entry><entry><title type="html">PyWPS Deployment</title><link href="https://chenzhang.org/notes/developer/pywps-deployment/" rel="alternate" type="text/html" title="PyWPS Deployment" /><published>2021-03-11T00:00:00+00:00</published><updated>2021-03-11T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/pywps-deployment</id><content type="html" xml:base="https://chenzhang.org/notes/developer/pywps-deployment/"><![CDATA[<p>A quick note of configuring a conda environment for PyWPS on Ubuntu.
Test environment: Ubuntu 20.04 LTS (Focal Fossa) 64-bit, Python 3.8, PyWPS 4.4.2</p>

<h2 id="installation">Installation</h2>

<p>Create conda environment for PyWPS:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>conda create <span class="nt">-n</span> <span class="s2">"pywps"</span> <span class="nv">python</span><span class="o">=</span>3.8
</code></pre></div></div>

<p>Install PyWPS and dependencies:</p>

<div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gh">#Latest PyWPS</span>
conda install -c conda-forge pywps

<span class="gh">#Optional packages</span>
conda install numpy
conda install gdal
conda install -c conda-forge pillow
</code></pre></div></div>

<p>Install and enable Apache WSGI for Python 3:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>apt-get <span class="nb">install </span>libapache2-mod-wsgi-py3
<span class="nb">sudo </span>a2enmod wsgi
</code></pre></div></div>

<h2 id="configuration">Configuration</h2>

<p>Create WPS Directory <code class="language-plaintext highlighter-rouge">/usr/local/pywps</code> and create <code class="language-plaintext highlighter-rouge">pywps.wsgi</code>:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#!/usr/bin/env python3
</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="s">"/usr/local/anaconda3/envs/pywps/lib/python3.8/site-packages/"</span><span class="p">)</span>
<span class="n">sys</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="s">"/usr/local/pywps/processes"</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">pywps.app.Service</span> <span class="kn">import</span> <span class="n">Service</span>

<span class="c1"># processes need to be installed in PYTHON_PATH
</span><span class="kn">from</span> <span class="nn">processes.sleep</span> <span class="kn">import</span> <span class="n">Sleep</span>
<span class="kn">from</span> <span class="nn">processes.ultimate_question</span> <span class="kn">import</span> <span class="n">UltimateQuestion</span>
<span class="kn">from</span> <span class="nn">processes.centroids</span> <span class="kn">import</span> <span class="n">Centroids</span>
<span class="kn">from</span> <span class="nn">processes.sayhello</span> <span class="kn">import</span> <span class="n">SayHello</span>
<span class="kn">from</span> <span class="nn">processes.feature_count</span> <span class="kn">import</span> <span class="n">FeatureCount</span>
<span class="kn">from</span> <span class="nn">processes.buffer</span> <span class="kn">import</span> <span class="n">Buffer</span>
<span class="kn">from</span> <span class="nn">processes.area</span> <span class="kn">import</span> <span class="n">Area</span>

<span class="n">processes</span> <span class="o">=</span> <span class="p">[</span>
    <span class="n">FeatureCount</span><span class="p">(),</span>
    <span class="n">SayHello</span><span class="p">(),</span>
    <span class="n">Centroids</span><span class="p">(),</span>
    <span class="n">UltimateQuestion</span><span class="p">(),</span>
    <span class="n">Sleep</span><span class="p">(),</span>
    <span class="n">Buffer</span><span class="p">(),</span>
    <span class="n">Area</span><span class="p">()</span>
<span class="p">]</span>

<span class="c1"># Service accepts two parameters:
# 1 - list of process instances
# 2 - list of configuration files
</span><span class="n">application</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span>
    <span class="n">processes</span><span class="p">,</span>
    <span class="p">[</span><span class="s">'/usr/local/pywps/pywps.cfg'</span><span class="p">]</span>
</code></pre></div></div>

<p>Create <code class="language-plaintext highlighter-rouge">pywps.cfg</code>:</p>

<p>According to <em><a href="https://pywps.readthedocs.io/en/master/configuration.html">https://pywps.readthedocs.io/en/master/configuration.html</a></em>:</p>

<p>Create <code class="language-plaintext highlighter-rouge">processes</code> directory and <code class="language-plaintext highlighter-rouge">logs</code> directory:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir </span>processes
<span class="nb">mkdir </span>workdir
<span class="nb">mkdir </span>logs
<span class="nb">chmod </span>777 logs
<span class="nb">chmod </span>777 workdir
<span class="nb">touch </span>logs/pywps.log
<span class="nb">chmod </span>777 logs/pywps.log
</code></pre></div></div>

<p>Create a configuration file <code class="language-plaintext highlighter-rouge">/etc/apache2/sites-enabled/pywps.conf</code>:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># PyWPS</span>
WSGIDaemonProcess pywps <span class="nv">home</span><span class="o">=</span>/usr/local/pywps <span class="nv">user</span><span class="o">=</span>www-data <span class="nv">group</span><span class="o">=</span>www-data <span class="nv">processes</span><span class="o">=</span>2 <span class="nv">threads</span><span class="o">=</span>5
WSGIScriptAlias /pywps /usr/local/pywps/pywps.wsgi process-group<span class="o">=</span>pywps
&lt;Directory /usr/local/pywps/&gt;
WSGIScriptReloading On
WSGIProcessGroup pywps
WSGIApplicationGroup %<span class="o">{</span>GLOBAL<span class="o">}</span>
Require all granted
&lt;/Directory&gt;
</code></pre></div></div>

<h2 id="test">Test</h2>

<p><a href="http://localhost/wps?request=GetCapabilities&amp;service=WPS">http://localhost/pywps?request=GetCapabilities&amp;service=WPS</a></p>

<h2 id="issues">Issues</h2>

<h3 id="no-module-named-gdal">No module named gdal’’</h3>

<p>Solution: install numpy may fix the gdal module issue.</p>

<h3 id="no-module-named-pywpsappservice">No module named pywps.app.Service</h3>

<p>This issue happens when the Python runtime is not being targeted to the conda environment. The message would be like:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>Wed Mar 17 11:35:24.851659 2021] <span class="o">[</span>wsgi:error] <span class="o">[</span>pid 79590:tid 139628017260288] <span class="o">[</span>remote 10.28.140.89:50116] mod_wsgi <span class="o">(</span><span class="nv">pid</span><span class="o">=</span>79590<span class="o">)</span>: Failed to <span class="nb">exec </span>Python script file <span class="s1">'/usr/local/pywps/pywps.wsgi'</span><span class="nb">.</span>
<span class="o">[</span>Wed Mar 17 11:35:24.851713 2021] <span class="o">[</span>wsgi:error] <span class="o">[</span>pid 79590:tid 139628017260288] <span class="o">[</span>remote 10.28.140.89:50116] mod_wsgi <span class="o">(</span><span class="nv">pid</span><span class="o">=</span>79590<span class="o">)</span>: Exception occurred processing WSGI script <span class="s1">'/usr/local/pywps/pywps.wsgi'</span><span class="nb">.</span>
<span class="o">[</span>Wed Mar 17 11:35:24.851782 2021] <span class="o">[</span>wsgi:error] <span class="o">[</span>pid 79590:tid 139628017260288] <span class="o">[</span>remote 10.28.140.89:50116] Traceback <span class="o">(</span>most recent call last<span class="o">)</span>:
<span class="o">[</span>Wed Mar 17 11:35:24.851827 2021] <span class="o">[</span>wsgi:error] <span class="o">[</span>pid 79590:tid 139628017260288] <span class="o">[</span>remote 10.28.140.89:50116]   File <span class="s2">"/usr/local/pywps/pywps.wsgi"</span>, line 3, <span class="k">in</span> &lt;module&gt;
<span class="o">[</span>Wed Mar 17 11:35:24.851896 2021] <span class="o">[</span>wsgi:error] <span class="o">[</span>pid 79590:tid 139628017260288] <span class="o">[</span>remote 10.28.140.89:50116]     from pywps.app.Service import Service
<span class="o">[</span>Wed Mar 17 11:35:24.851942 2021] <span class="o">[</span>wsgi:error] <span class="o">[</span>pid 79590:tid 139628017260288] <span class="o">[</span>remote 10.28.140.89:50116] ImportError: No module named pywps.app.Service
</code></pre></div></div>

<p>Solution: add <code class="language-plaintext highlighter-rouge">sys.path.append("/usr/local/anaconda3/envs/pywps/lib/python3.8/site-packages/"</code> in <code class="language-plaintext highlighter-rouge">pywps.wsgi</code>.</p>

<h2 id="reference">Reference</h2>

<p><a href="https://github.com/geopython/pywps/">https://github.com/geopython/pywps/</a></p>

<p><a href="https://pywps.readthedocs.io/en/master/deployment.html">https://pywps.readthedocs.io/en/master/deployment.html</a></p>

<p><a href="https://faun.pub/how-to-set-up-conda-virtual-environments-with-apache-mod-wsgi-flask-c2043711223e">https://faun.pub/how-to-set-up-conda-virtual-environments-with-apache-mod-wsgi-flask-c2043711223e</a></p>

<p><a href="https://stackoverflow.com/questions/45289299/python-3-4-importerror-no-module-named-gdal-arrayno-module-named-gdal-arra">https://stackoverflow.com/questions/45289299/python-3-4-importerror-no-module-named-gdal-arrayno-module-named-gdal-arra</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Ubuntu" /><category term="#Python" /><category term="#PyWPS" /><summary type="html"><![CDATA[A quick note of configuring a conda environment for PyWPS on Ubuntu. Test environment: Ubuntu 20.04 LTS (Focal Fossa) 64-bit, Python 3.8, PyWPS 4.4.2]]></summary></entry><entry><title type="html">Installing TerriaJS on Ubuntu</title><link href="https://chenzhang.org/notes/developer/terriajs-installation/" rel="alternate" type="text/html" title="Installing TerriaJS on Ubuntu" /><published>2020-06-10T00:00:00+00:00</published><updated>2020-06-10T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/terriajs-installation</id><content type="html" xml:base="https://chenzhang.org/notes/developer/terriajs-installation/"><![CDATA[<p>The TerriaJS Map is a web-based geospatial catalog explorer powered by the TerriaJS library to display and manage 2D/3D/4D geospatial data layers. It supports common geospatial data formats, such as GeoJSON, KML, CSV, GPX, CZML, and shapefile, as well as geospatial web services including WMS, WFS, WMTS, Esri MapServer, ABS ITT, Bing Maps, OpenStreetMap-style raster tiles, and Mapbox. The TerriaJS has been enabled in collaboration with geospatial data platforms of government agencies and organizations, such as Australia’s NationalMap (https://nationalmap.gov.au/), National Environmental Information Infrastructure (http://neii.gov.au/viewer/), State of Environment 2016 (https://soe.terria.io/), Group on Earth Observations (GEO) and its Global Agricultural Monitoring (GEOGLAM) Rangeland and Pasture Productivity (https://map.geo-rapp.org/), and many other applications.</p>

<h2 id="installation">Installation</h2>

<h3 id="gdal">GDAL</h3>

<p>Import the minted package:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>add-apt-repository ppa:ubuntugis/ppa
<span class="nb">sudo </span>apt-get update
<span class="nb">sudo </span>apt-get <span class="nb">install </span>gdal-bin
</code></pre></div></div>

<h3 id="node">Node</h3>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>curl <span class="nt">-sL</span> https://deb.nodesource.com/setup_10.x | <span class="nb">sudo</span> <span class="nt">-E</span> bash -
<span class="nb">sudo </span>apt-get <span class="nb">install</span> <span class="nt">-y</span> nodejs
node <span class="nt">--version</span>
npm <span class="nt">--version</span>
</code></pre></div></div>

<h3 id="gulp">Gulp</h3>

<p>npm run gulp:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm <span class="nb">install</span> <span class="nt">--save-dev</span> <span class="nt">-g</span> gulp
</code></pre></div></div>

<h3 id="terriajs">TerriaJS</h3>

<p>Install TerriaJS:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/TerriaJS/TerriaJS.git
npm <span class="nb">install</span>
</code></pre></div></div>

<p>Install TerriaJS Map:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/TerriaJS/TerriaMap.git
npm <span class="nb">install</span>
</code></pre></div></div>

<p>Build:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm run gulp release
</code></pre></div></div>

<p>Start:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm start
</code></pre></div></div>

<p>Deploy and hide the port:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ProxyPass /terria/ http://localhost:3001/
ProxyPassReverse /terria/ http://localhost:3001/
</code></pre></div></div>

<h2 id="qa">Q&amp;A</h2>

<p>Github connection error while installing with npm:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm ERR! git clone <span class="nt">--template</span><span class="o">=</span>/root/.npm/_git-remotes/_templates <span class="nt">--mirror</span> git://github.com/TerriaJS/pell.git /root/.npm/_git-remotes/git-github-com-TerriaJS-pell-git-master-d15617c6: Cloning into bare repository <span class="s1">'/root/.npm/_git-remotes/git-github-com-TerriaJS-pell-git-master-d15617c6'</span>...
npm ERR! git clone <span class="nt">--template</span><span class="o">=</span>/root/.npm/_git-remotes/_templates <span class="nt">--mirror</span> git://github.com/TerriaJS/pell.git /root/.npm/_git-remotes/git-github-com-TerriaJS-pell-git-master-d15617c6: fatal: unable to connect to github.com:
npm ERR! git clone <span class="nt">--template</span><span class="o">=</span>/root/.npm/_git-remotes/_templates <span class="nt">--mirror</span> git://github.com/TerriaJS/pell.git /root/.npm/_git-remotes/git-github-com-TerriaJS-pell-git-master-d15617c6: github.com[0: 140.82.113.4]: <span class="nv">errno</span><span class="o">=</span>Connection timed out
npm ERR! code 128
npm ERR! Command failed: git clone <span class="nt">--template</span><span class="o">=</span>/root/.npm/_git-remotes/_templates <span class="nt">--mirror</span> git://github.com/TerriaJS/pell.git /root/.npm/_git-remotes/git-github-com-TerriaJS-pell-git-master-d15617c6
npm ERR! Cloning into bare repository <span class="s1">'/root/.npm/_git-remotes/git-github-com-TerriaJS-pell-git-master-d15617c6'</span>...
npm ERR! fatal: unable to connect to github.com:
npm ERR! github.com[0: 140.82.113.4]: <span class="nv">errno</span><span class="o">=</span>Connection timed out
npm ERR!
npm ERR!

npm ERR! A <span class="nb">complete </span>log of this run can be found <span class="k">in</span>:
npm ERR!     /root/.npm/_logs/2020-06-11T03_58_52_831Z-debug.log
</code></pre></div></div>

<p>Solution:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git config <span class="nt">--global</span> url.https://github.com/.insteadOf git://github.com/
</code></pre></div></div>

<h2 id="references">References</h2>

<p><a href="https://docs.terria.io/guide/getting-started/">TerriaJS: Getting Started</a></p>

<p><a href="https://serverfault.com/questions/429122/apache-virtualhost-proxy-with-a-subdirectory">Apache VirtualHost Proxy with a Subdirectory</a></p>

<p><a href="https://github.com/nodesource/distributions/blob/master/README.md">NodeSource Node.js Binary Distributions</a></p>

<p><a href="https://github.com/npm/npm/issues/6285">Fatal: Unable to connect to github.com #6285</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Terria" /><category term="#Ubuntu" /><summary type="html"><![CDATA[The TerriaJS Map is a web-based geospatial catalog explorer powered by the TerriaJS library to display and manage 2D/3D/4D geospatial data layers. It supports common geospatial data formats, such as GeoJSON, KML, CSV, GPX, CZML, and shapefile, as well as geospatial web services including WMS, WFS, WMTS, Esri MapServer, ABS ITT, Bing Maps, OpenStreetMap-style raster tiles, and Mapbox. The TerriaJS has been enabled in collaboration with geospatial data platforms of government agencies and organizations, such as Australia’s NationalMap (https://nationalmap.gov.au/), National Environmental Information Infrastructure (http://neii.gov.au/viewer/), State of Environment 2016 (https://soe.terria.io/), Group on Earth Observations (GEO) and its Global Agricultural Monitoring (GEOGLAM) Rangeland and Pasture Productivity (https://map.geo-rapp.org/), and many other applications.]]></summary></entry><entry><title type="html">Enabling Minted in Latex</title><link href="https://chenzhang.org/notes/developer/enabling-minted-in-latex/" rel="alternate" type="text/html" title="Enabling Minted in Latex" /><published>2020-03-11T00:00:00+00:00</published><updated>2020-03-11T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/enabling-minted-in-latex</id><content type="html" xml:base="https://chenzhang.org/notes/developer/enabling-minted-in-latex/"><![CDATA[<p>Minted is a great package for latex users to insert colorful code in the manuscript. But enabling minted in latex might not as easy as other packages. Here are some tips to save your time.</p>

<h1 id="installation--configuration">Installation &amp; Configuration</h1>

<p>Note: This guide is based on MacTex.</p>

<h2 id="import-package">Import package</h2>

<p>Import the minted package:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\usepackage[cache=false,outputdir=build]{minted}
</code></pre></div></div>

<h2 id="add-shell-escape-option">Add –shell-escape option</h2>

<p>Make sure you are adding the <code class="language-plaintext highlighter-rouge">--shell-escape</code> option while building.</p>

<p>For example, if you are using the VS Code with <a href="https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop">latex-workshop</a>, you have to add the <code class="language-plaintext highlighter-rouge">--shell-escape</code> option in the setting:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>"latex-workshop.latex.tools": [
    {
        "args": [
            "--output-directory=build",
            "-interaction=nonstopmode",
            "-synctex=1",
            "--shell-escape",
            "%DOC%"
        ],
        "command": "pdflatex",
        "name": "pdflatex"
    }
    ...
]
</code></pre></div></div>

<h2 id="install-pygments">Install pygments</h2>

<p>If you see the error “You must have `pygmentize’ installed to use this package”. You have to install the pygments.</p>

<p>For mac user:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew install pygments
</code></pre></div></div>

<h1 id="references">References</h1>

<p><a href="https://github.com/SublimeText/LaTeXTools/issues/657">LaTeXTools can’t find installed pygmentize package</a></p>

<p><a href="https://www.zhihu.com/question/33587455">如何在mac的latex上使用minted宏包？</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Latex" /><category term="#macOS" /><summary type="html"><![CDATA[Minted is a great package for latex users to insert colorful code in the manuscript. But enabling minted in latex might not as easy as other packages. Here are some tips to save your time.]]></summary></entry><entry><title type="html">Changing Default File Permission in Linux</title><link href="https://chenzhang.org/notes/developer/changing-default-file-permission-in-linux/" rel="alternate" type="text/html" title="Changing Default File Permission in Linux" /><published>2020-02-11T00:00:00+00:00</published><updated>2020-02-11T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/changing-default-file-permission-in-linux</id><content type="html" xml:base="https://chenzhang.org/notes/developer/changing-default-file-permission-in-linux/"><![CDATA[<h2 id="change-the-default-permissions-for-new-files">Change the default permissions for new files</h2>

<h3 id="umask">umask</h3>

<p>Check the umask value for the current directory:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>umask
</code></pre></div></div>

<p>Change the default umask value for the current directory, for example:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>umask u=,g=w,o=rwx
</code></pre></div></div>

<h3 id="setfacl">setfacl</h3>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>setfacl -d -m g::rwx .
</code></pre></div></div>

<h2 id="references">References</h2>

<p><a href="https://geek-university.com/linux/set-the-default-permissions-for-newly-created-files/">Set the default permissions for newly created files</a></p>

<p><a href="https://docs.oracle.com/cd/E19683-01/817-3814/userconcept-95347/index.html">Default File Permissions (umask)</a></p>

<p><a href="https://askubuntu.com/questions/44534/how-to-set-umask-for-a-specific-folder">How to set umask for a specific folder</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#Linux" /><summary type="html"><![CDATA[Change the default permissions for new files]]></summary></entry><entry><title type="html">CKAN Postgre Database Migration</title><link href="https://chenzhang.org/notes/developer/ckan-postgres-database-migration/" rel="alternate" type="text/html" title="CKAN Postgre Database Migration" /><published>2019-12-04T00:00:00+00:00</published><updated>2019-12-04T00:00:00+00:00</updated><id>https://chenzhang.org/notes/developer/ckan-postgres-database-migration</id><content type="html" xml:base="https://chenzhang.org/notes/developer/ckan-postgres-database-migration/"><![CDATA[<p>The CKAN postgres database might take a lot of spaces in the Linux system. Today I notice the disk of our CKAN system is almost full. So I have to move the entire databse to an external disk. As you know, any modification of database could be dangerous. It takes me whole afternoon to deal with and I recorded the key steps of the migration. Here we go through how to migrate the CKAN postgres database in Ubuntu 16.04.</p>

<h2 id="preparation">Preparation</h2>

<p>Check current database location, usually located at <code class="language-plaintext highlighter-rouge">/var/lib/postgresql</code> by default:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo -u postgres psql
SHOW data_directory;
\q
</code></pre></div></div>

<p>Stop CKAN and postgres service:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>service apache2 stop
service nginx stop
service postgresql stop
</code></pre></div></div>

<p>Copy data from original location to target location:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cp -R /var/lib/postgresql NEW_LOCATION
</code></pre></div></div>

<p>Change permission:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>chmod 700 -R NEW_LOCATION
chown -R postgres:postgres NEW_LOCATION
</code></pre></div></div>

<h2 id="target-database-to-new-location">Target Database to New Location</h2>

<h3 id="solution-1-update-database-configuration">Solution 1: Update Database Configuration</h3>

<p>Edit <code class="language-plaintext highlighter-rouge">/etc/postgresql/9.5/main/postgresql.conf</code> and update the new location:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>data_directory = '[NEW_LOCATION]'
</code></pre></div></div>

<p>Start the postgres service:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>service postgresql start
</code></pre></div></div>

<p>Check the log of postgres to make sure it is successfully started:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>tail -f /var/log/postgresql/postgresql-9.5-main.log
</code></pre></div></div>

<p>Remove the old database if needed:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rm -rf /var/lib/postgresql
</code></pre></div></div>

<h3 id="solution-2-link-to-the-new-location">Solution 2: Link to the new location</h3>

<p>I tried to soft link the default directory to the new location but failed for some reason, might be caused by the permission issue:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ln -s NEW_LOCATION /var/lib/postgresql
</code></pre></div></div>

<p>It should work with the correct permission configuration but need to be further tested.</p>

<h2 id="automount-disk-for-external-disk-only">Automount Disk (for external disk only)</h2>

<p>Get the UUID of the external disk:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>blkid
</code></pre></div></div>

<p>Copy the UUID of the target disk, edit <code class="language-plaintext highlighter-rouge">/etc/fstab</code> and add the following line:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>UUID=[UUID_OF_TARGET_DISK] [MOUNT_POINT] ext4  defaults       0  0
</code></pre></div></div>

<h2 id="qa">Q&amp;A</h2>

<p>I ran into this issue while checking the new database location with <code class="language-plaintext highlighter-rouge">sudo -u postgres psql</code>:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket
</code></pre></div></div>

<p>or</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>psql: could not connect to server: No such file or directory

Is the server running locally and accepting connections on 
Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
</code></pre></div></div>

<p>A <a href="https://stackoverflow.com/questions/13573204/psql-could-not-connect-to-server-no-such-file-or-directory-mac-os-x/21503349">potential solution</a> is removing <code class="language-plaintext highlighter-rouge">postmaster.pid</code> in the postgres database directory. <del>I am not sure how did I solved this issue, maybe by removing the <code class="language-plaintext highlighter-rouge">postmaster.pid</code> or updating the permission.</del></p>

<p>According to <a href="https://stackoverflow.com/questions/42653690/psql-could-not-connect-to-server-no-such-file-or-directory-5432-error">https://stackoverflow.com/questions/42653690/psql-could-not-connect-to-server-no-such-file-or-directory-5432-error</a>, the permission error would lead this error:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@uddi:/etc/postgresql/9.5/main# pg_ctlcluster 9.5 main start
Error: Config owner <span class="o">(</span>postgres:123<span class="o">)</span> and data owner <span class="o">(</span>root:0<span class="o">)</span> <span class="k">do </span>not match, and config owner is not root
</code></pre></div></div>

<p>Please make sure the owner of data directory and its subdirectories is <code class="language-plaintext highlighter-rouge">postgres</code>.</p>

<h2 id="references">References</h2>

<p><a href="https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-16-04">How To Move a PostgreSQL Data Directory to a New Location on Ubuntu 16.04</a></p>

<p><a href="https://community.linuxmint.com/tutorial/view/1513">Editing fstab to automount partitions at startup</a></p>]]></content><author><name></name></author><category term="Developer" /><category term="#CKAN" /><category term="#Postgre" /><summary type="html"><![CDATA[The CKAN postgres database might take a lot of spaces in the Linux system. Today I notice the disk of our CKAN system is almost full. So I have to move the entire databse to an external disk. As you know, any modification of database could be dangerous. It takes me whole afternoon to deal with and I recorded the key steps of the migration. Here we go through how to migrate the CKAN postgres database in Ubuntu 16.04.]]></summary></entry></feed>