Posts

Showing posts with the label FreeBDS

Python3 + Django + uWSGI + Nginx On FreeBSD

1. uWSGI Installation. $ sudo pip-3.6 install uwsgi Collecting uwsgi Downloading uwsgi-2.0.17.tar.gz (798kB) 100% |################################| 798kB 709kB/s Installing collected packages: uwsgi Running setup.py install for uwsgi ... done Successfully installed uwsgi-2.0.17 1.1 Basic test Let’s start with a simple “Hello World” example: def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return [b"Hello World"] As you can see, it is composed of a single Python function. It is called “application” as this is the default function that the uWSGI Python loader will search for (but you can obviously customize it). 1.2 Now start uWSGI to run an HTTP server/router passing requests to your WSGI application: uwsgi --http :9090 --wsgi-file foobar.py 2.Installing Django. Install Django into your virtualenv , create a new project $ mkproject django $ pip install Django Collecting Django ...

[FreeBSD] Installing and using Python's virtualenv using Python3

1. Installing Python3. $ sudo pkg install python36 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 2 package(s) will be affected (of 0 checked): New packages to be INSTALLED: python36: 3.6.4 libffi: 3.2.1_2 Number of packages to be installed: 2 The process will require 103 MiB more space. 15 MiB to be downloaded. Proceed with this action? [y/N]: y [1/2] Fetching python36-3.6.4.txz: 100% 15 MiB 15.5MB/s 00:01 [2/2] Fetching libffi-3.2.1_2.txz: 100% 34 KiB 35.3kB/s 00:01 Checking integrity... done (0 conflicting) [1/2] Installing libffi-3.2.1_2... [1/2] Extracting libffi-3.2.1_2: 100% [2/2] Installing python36-3.6.4... Extracting python36-3.6.4: 100% Message from python36-3.6.4: =========================================================================== Note that some standard Python modules are provided as separate ports as they require additional dependencies. They are availabl...

FreeBSD: Configuring Apache to permit CGI

In httpd.conf file make sure the "cgi" LoadModule directive has not been commented out. A correctly configured directive may look like this: <IfModule mpm_prefork_module> LoadModule cgi_module libexec/apache24/mod_cgi.so </IfModule> Explicitly using Options to permit CGI execution To allow CGI program execution for any file ending in .cgi in users' directories, you can use the following configuration. <VirtualHost *:80> DocumentRoot "/usr/local/www/apache24/e" ServerName www.example.com ErrorLog "/var/log/e-error_log" CustomLog "/var/log/e-access_log" common <Directory "/usr/local/www/apache24/e/"> Order allow,deny Allow from all Require all granted Options +ExecCGI AddHandler cgi-script .cgi </Directory> </VirtualHost> <Directory "/home/*/public_html"> Options +ExecCGI AddHandler cgi-script .cgi </Di...

Installing Apache2.4, PHP7.1 on FreeBSD

1.Install and configure Apache 2.4 Let's install Apache 2.4 first. please refer to this link . 2.Install and configure PHP 7.1 $ sudo pkg install mod_php71 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: mod_php71: 7.1.12 Number of packages to be installed: 1 The process will require 4 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: y [1/1] Fetching mod_php71-7.1.12.txz: 100% 1 MiB 1.2MB/s 00:01 Checking integrity... done (0 conflicting) [1/1] Installing mod_php71-7.1.12... Extracting mod_php71-7.1.12: 100% [activating module `php7' in /usr/local/etc/apache24/httpd.conf] Message from mod_php71-7.1.12: *************************************************************** Make sure index.php is part of your DirectoryIndex. You should add the following to your Apache configuration file: ...

Install Tomcat8.5 on FreeBSD

Perform this command to install Tomcat8.5 $ sudo pkg install tomcat85 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 2 package(s) will be affected (of 0 checked): New packages to be INSTALLED: tomcat85: 8.5.23 jakarta-commons-daemon: 1.0.15 Number of packages to be installed: 2 The process will require 13 MiB more space. 9 MiB to be downloaded. Proceed with this action? [y/N]: y [1/2] Fetching tomcat85-8.5.23.txz: 100% 9 MiB 9.0MB/s 00:01 [2/2] Fetching jakarta-commons-daemon-1.0.15.txz: 100% 89 KiB 91.5kB/s 00:01 Checking integrity... done (0 conflicting) [1/2] Installing jakarta-commons-daemon-1.0.15... [1/2] Extracting jakarta-commons-daemon-1.0.15: 100% [2/2] Installing tomcat85-8.5.23... Extracting tomcat85-8.5.23: 100% add tomcat85_enable=YES to /etc/rc.conf file. $ sudo sysrc tomcat85_enable=YES tomcat85_enable: -> YES start tomcat8.5 $ sudo service tomcat85 s...

How To Install JDK on FreeBSD

To install OpenJDK® 8 package use the pkg utility: $ sudo pkg install openjdk8 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 31 package(s) will be affected (of 0 checked): New packages to be INSTALLED: openjdk8: 8.144.1 libXtst: 1.2.3 recordproto: 1.14.2 libXi: 1.7.9,1 xproto: 7.0.31 libXfixes: 5.0.3 libX11: 1.6.5,1 libxcb: 1.12_2 libXdmcp: 1.1.2 libXau: 1.0.8_3 libpthread-stubs: 0.4 kbproto: 1.0.7 fixesproto: 5.0 libXext: 1.3.3_1,1 xextproto: 7.3.0 inputproto: 2.3.2 libXrender: 0.9.10 renderproto: 0.11.1 libXt: 1.1.5,1 libSM: 1.2.2_3,1 libICE: 1.0.9_1,1 fontconfig: 2.12.1,1 freetype2: 2.8 dejavu: 2.37 mkfontscale: 1.1.2 libfontenc: 1.1.3_1 mkfontdir: 1.0.7 javavmwrapper: 2.5_2 ja...

Installing Apache24 on FreeBSD.

Step 1. Perform an update on your system. freebsd-update fetch freebsd-update install Step 2. Install and configure Apache24. $ sudo pkg install apache24 Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 6 package(s) will be affected (of 0 checked): New packages to be INSTALLED: apache24: 2.4.27_1 expat: 2.2.1 pcre: 8.40_1 apr: 1.6.2.1.6.0 gdbm: 1.13_1 db5: 5.3.28_6 Number of packages to be installed: 6 The process will require 83 MiB more space. 19 MiB to be downloaded. Proceed with this action? [y/N]: y [1/6] Fetching apache24-2.4.27_1.txz: 100% 5 MiB 5.1MB/s 00:01 [2/6] Fetching expat-2.2.1.txz: 100% 111 KiB 113.2kB/s 00:01 [3/6] Fetching pcre-8.40_1.txz: 100% 1 MiB 1.2MB/s 00:01 [4/6] Fetching apr-1.6.2.1.6.0.txz: 100% 453 KiB 464.0kB/s 00:01 [5/6] Fetching gdbm-1.13_1.txz: 100% 151 KiB 155.0kB/s 00:01 [6/6] Fetching db5-5.3.28...

How do I configure Dynamic DNS Client on FreeBSD.

In First, Confirm your Domain's Nameserver has been modified. NS1.AFRAID.ORG NS2.AFRAID.ORG NS3.AFRAID.ORG NS4.AFRAID.ORG step 1. Install ddClient from ports. $ sudo pkg install ddclient Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 4 package(s) will be affected (of 0 checked): New packages to be INSTALLED: ddclient: 3.8.3_3 p5-IO-Socket-SSL: 2.051 p5-Mozilla-CA: 20160104 p5-Net-SSLeay: 1.81 Number of packages to be installed: 4 The process will require 2 MiB more space. 590 KiB to be downloaded. Proceed with this action? [y/N]: y [1/4] Fetching ddclient-3.8.3_3.txz: 100% 43 KiB 44.5kB/s 00:01 [2/4] Fetching p5-IO-Socket-SSL-2.051.txz: 100% 158 KiB 162.1kB/s 00:01 [3/4] Fetching p5-Mozilla-CA-20160104.txz: 100% 147 KiB 150.0kB/s 00:01 [4/4] Fetching p5-Net-SSLeay-1.81.txz: 100% 242 KiB 247.4kB/s 00:01 Checking integrity... done (0 conflicting) [1...

NAP,DZM,UPnP How to do Port- Forwarding (Open a Port) in your Router.

1.NAP Network address translation (NAT) is a method of remapping one IP address space into another by modifying network address information in Internet Protocol (IP) datagram packet headers while they are in transit across a traffic routing device.[1] The technique was originally used for ease of rerouting traffic in IP networks without readdressing every host. In more advanced NAT implementations featuring IP masquerading, it has become a popular and essential tool in conserving global address space allocations in face of IPv4 address exhaustion by sharing one Internet-routable IP address of a NAT gateway for an entire private network. 2.DMZ n computer security, a DMZ or demilitarized zone (sometimes referred to as a perimeter network) is a physical or logical subnetwork that contains and exposes an organization's external-facing services to an untrusted network, usually a larger network such as the Internet. The purpose of a DMZ is to add an additional layer of security to an...

Install curl & wget On FreeBSD

1.Run this command to Install curl. $ sudo pkg install curl Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 3 package(s) will be affected (of 0 checked): New packages to be INSTALLED: curl: 7.56.1 libnghttp2: 1.26.0 ca_root_nss: 3.32.1 Number of packages to be installed: 3 The process will require 5 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: y [1/3] Fetching curl-7.56.1.txz: 100% 1 MiB 1.2MB/s 00:01 [2/3] Fetching libnghttp2-1.26.0.txz: 100% 104 KiB 106.3kB/s 00:01 Checking integrity... done (0 conflicting) [1/3] Installing libnghttp2-1.26.0... [1/3] Extracting libnghttp2-1.26.0: 100% [2/3] Installing ca_root_nss-3.32.1... Extracting ca_root_nss-3.32.1: 100% [1/3] Installing curl-7.56.1... [1/3] Extracting curl-7.56.1: 100% Message from ca_root_nss-3.32.1: ********************************* WARNING ********************************* FreeBSD doe...

FreeBSD: Install & Config Samba

1.At first update the server’s repository information. $ sudo pkg update 2.Search Samba in PKG. $ pkg search samba 3.Install the last version Samba. $ sudo pkg install samba46 Sample Output: Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 33 package(s) will be affected (of 0 checked): New packages to be INSTALLED: samba46: 4.6.8 libsunacl: 1.0 gnutls: 3.5.15 trousers: 0.3.14_1 tpm-emulator: 0.7.4_2 gmp: 6.1.2 p11-kit: 0.23.8 libtasn1: 4.12 ca_root_nss: 3.32.1 libffi: 3.2.1_1 libiconv: 1.14_11 nettle: 3.3 libidn2: 2.0.4 libunistring: 0.9.7 openldap-client: 2.4.45 python27: 2.7.14 python2: 2_3 py27-dnspython: 1.15.0 py27-setuptools: 36.2.2 tevent: 0.9.31 talloc: 2.1.9 py27-iso8601: 0.1.11 popt: 1.16_2 libinotify: 20170711_1 gamin: 0.1.10_9 glib: 2.50.2_6,1 pcre: 8.40_1 tdb: 1.3.12,1 ldb: 1.1.29_1 libarchive: 3.3.1,1 expat: 2.2.1 lzo2: 2.10_1 liblz4: 1.8.0,1 Number of...

FreeBSD: Install PostgreSQL Server & Client

1.At first update the server’s repository information. $ sudo pkg update 2.Search PostgreSQL in PKG. $ pkg search postgresql 3.Install the last version PostgreSQL. $ sudo pkg install postgresql10-server Sample Output: Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 5 package(s) will be affected (of 0 checked): New packages to be INSTALLED: postgresql10-server: 10.1 libxml2: 2.9.4 postgresql10-client: 10.1 perl5: 5.24.3 readline: 7.0.3 Number of packages to be installed: 5 The process will require 88 MiB more space. 21 MiB to be downloaded. Proceed with this action? [y/N]: y [1/5] Fetching postgresql10-server-10.1.txz: 100% 4 MiB 4.1MB/s 00:01 [2/5] Fetching libxml2-2.9.4.txz: 100% 802 KiB 820.8kB/s 00:01 [3/5] Fetching postgresql10-client-10.1.txz: 100% 2 MiB 2.6MB/s 00:01 [4/5] Fetching perl5-5.24.3.txz: 100% 13 MiB 14.0MB/s 00:01 [5/5] Fetching readlin...

FreeBSD: Update/Upgrade

config file: /etc/freebsd-update.conf 1.Run this command to update FreeBSD. # freebsd-update fetch # freebsd-update install daily update job: /etc/crobntab @daily root freebsd-update cron 2.Run this command to Uninstalling updates. # freebsd-update rollback 3.Run this command to Upgrade. # freebsd-update -r xx.x-RELEASE upgrade # freebsd-update install

FreeBSD: Install sudo Command, Allow wheel Group Users To Execute A Command As The Root [Without a Password]

1.Update the pkg tool # pkg update 2.Install sudo # pkg install sudo 3.Run 'visudo' command to configure sudo. # visudo 4.Uncomment to Allow members of group wheel to execute any command. # %wheel ALL=(ALL) ALL 5.Uncomment to Allow members of group wheel to execute any command without a password. # %wheel ALL=(ALL) NOPASSWD: ALL 6.Save and close the file.

How To Configure SSH Key-Based Authentication on a FreeBSD Server

1.In your local computer's terminal, generate a key pair with this command. $ ssh-keygen -t rsa -C "user@server" -b 4096 -f ~/.ssh/filename 2.Copy the public key to your server. $ ssh-copy-id -i ~/.ssh/filename[.pub] user@server If ssh-copy-id is not available on your machine , you will need to do this by hand. Copy the contents of filename.pub to ~/.ssh/authorized_keys $ cat .ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys' $ ssh user@server "chmod 700 .ssh; chmod 640 .ssh/authorized_keys" [OR] $ scp ~/.ssh/id_rsa.pub user@server:~ $ mkdir -p ~/.ssh $ touch ~/.ssh/authorized_keys $ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys $ rm ~/id_rsa.pub $ chmod 600 ~/.ssh/authorized_keys $ chmod 700 ~/.ssh 3.In your server, To confirm the public key has been copied. $ cat ~/.ssh/authorized_keys 4.Backup the /etc/ssh/sshd_config file. $ cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak 5.Edit the /etc/ssh/sshd_config file....

The Simplest Way to Monitor CPU Temperature in FreeBSD

Load kernel module.(need root permissions). 'coretemp' for Intel series CPU. 'amdtemp' for AMD series CPU. # kldload coretemp Type these words, the temperature will be displayed. # sysctl dev.cpu | grep temperature Unload kernel module. # kldunload coretemp

Run on start up in FreeBSD

1.Crontab "@reboot" ... 0 2 * * 1 root /usr/local/bin/certbot renew --renew-hook "service apache24 restart" -q #upnpc * * * * * root /usr/local/bin/upnpc.sh @reboot mosq:wheel /usr/local/bin/python3 /home/mosq/.workspace.py/python3/ilohas/ilohas/spider/batch/runner.py 2./etc/rc add a line just before ending line. ... /usr/local/bin/uwsgi --emperor /usr/local/etc/uwsgi/vassals --uid www --gid www --daemonize /var/log/uwsgi-emperor.log exit 0 3.Create a script as System service. path:/usr/local/etc/rc.d/ For a example #!/bin/sh # PROVIDE: miniupnpc # REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv # KEYWORD: shutdown . /etc/rc.subr # Add the following lines to /etc/rc.conf to enable miniupnpc # miniupnpc_enable="YES" # miniupnpc_config="port protocol [port2 protocol2] [...]" name="miniupnpc" rcvar=miniupnpc_enable load_rc_config $name miniupnpc_enable=${miniupnpc_enable:-"NO"} command="/usr/local/b...

Solr Cloud Mode on FREEBSD

1.Set Bash as the default shell. 2.Create the groups and users zookeeper:*:962: solr:*:161: ... zookeeper:*:962:962:zookeeper user:/nonexistent:/usr/sbin/nologin solr:*:161:161:Apache Solr System:/var/db/solr:/usr/sbin/nologin 3.Download zookeeper and solr from https://zookeeper.apache.org/releases.html#download https://lucene.apache.org/solr/downloads.html and unzip them. curl -O https://xxxxxx OR wget https://xxxxxx 4.link path to /usr/local/etc tar zxf xxxx.gz sudo ln -s /usr/local/etc/solr ~/solr.xx.xx sudo ln -s /usr/local/etc/zookeeper ~/zookeeper.xx.xx 5.Customize solr config copy solr/server/solr/configsets/_default to solr/server/solr/configsets/xxx_default and create file "data-config.xml" <dataconfig> <datasource driver="org.postgresql.Driver" url="jdbc:postgresql://localhost/postgres" user="pgu1" password="pgu1" /> <document> <entity name="item" query=...

[FreeBSD] How to change from sh to bash as default shell

1. Installing bash $ sudo pkg install bash Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: bash: 4.4.12_3 Number of packages to be installed: 1 The process will require 8 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: $ sudo pkg install bash Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: bash: 4.4.12_3 Number of packages to be installed: 1 The process will require 8 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: y [1/1] Fetching bash-4.4.12_3.txz: 100% 1 MiB 1.5MB/s 00:01 Checking integrity... done (0 conflicting) [1/1] Installing bash-4.4.12_3... Extracting bash-4.4.12_3: 100% 2. List of acceptable shel...

[FreeBSD] 3 Ways to Turn off a FreeBSD System

1. $sudo init 0 2. $sudo halt -p 3. $sudo shutdown -p now