To install openvpn in your MacOS Mojave or other version from Terminal, you can use brew, follow these steps:
brew install openvpn
After you success install it, add it’s path to your environment to make your work easier. You can export it directly to your $PATH environment variable, edit your .bash_profile file or insert into /etc/paths file, etc.
# Export
export PATH=$(brew --prefix openvpn)/sbin:$PATH
# Edit .bash_profile
# Add new line in this file with this code
export PATH=$(brew --prefix openvpn)/sbin:$PATH
# Edit /etc/paths
# Add new line in this file with this code
/usr/local/Cellar/openvpn/2.4.8/sbin
Last step, please enter command openvpn in your terminal, if error message “command not found” shown, that means you have to re-check your configuration. But if your openvpn installed successfully, just type this command below to start using openvpn.
sudo openvpn --config /path/to/your_config_file.ovpn