- name: webserver
- type: portjail (x64)
- Click 'save'
- Click 'jails'
- Click 'webserver'
- Click 'shell'
vi /etc/rc.conf
- change
sshd_enable="NO"
tosshd_enable="YES"
- start ssh daemon (sshd)
/etc/rc.d/sshd start
parameters: needs to belong to group "wheel" - reason? to enable SSH also make sure when choosing a shell input "bash" - otherwise csh will default, and this won't work
- type:
adduser
- Invite to login group 'wheel'
- Set shell path to bash (We'll install this in the next steps)
/usr/local/bin/bash
mkdir -p /home/www/sites
cp ~/.profile /home/www
(Copy our profile over to www, because it never had one to begin with)chown -R www:www /home/www
chpass www
- set home to
/home/www
- set shell to
/usr/local/bin/bash
pw usermod www -G wheel
In the shell that you launched for the web server jail you created we need to fetch extract and update our ports.
- portsnap fetch
- portsnap extract
- portsnap update
This will prompt for configuration options. Configure as you see fit. I recommend (in the subsequent dependent port installations, disabling EXAMPLES pic here
cd /usr/ports/shells/bash
make install clean
- I turn off P4 and CVS
cd /usr/ports/security/sudo
make install clean
- I like to select
INSULTS
andLDAP
as options vi /usr/local/etc/sudoers
- uncomment (remove '#') this line
# %wheel ALL=(ALL) ALL
(near the bottom of the file) wq!
(Write, Quit, Because I Said So)
NOTE: AT THIS POINT YOU CAN SSH INTO YOUR BOX IF YOU'D LIKE TO; NO MORE FreeNAS WEBGUI SHELL
If you do, and you log in with the user you created earlier, you'll likely need to install ports using the sudo
command. Oh, how convenient; we just installed that.
cd /usr/ports/devel/git
make install clean
- When it asks about
curl
, I install with LDAP/S and LIBSSH2 - When
ca_root_nss-3.16.1
select ETCSYMLINK - DOCS not needed for
xmlto
,getopt
,libgcrypt
,libgpg-error
,docbook-xsl
,xmlcatmgr
,w3m
,boehm-gc
,libatomic_ops
- EXAMPLES not needed for
python27
,p5*
(this will take a while, but stick with it)
cd /usr/ports/databases/mysql56-server
make install clean
echo 'mysql_enable="YES" >> /etc/rc.conf
cd /usr/ports/databases/sqlite3
make install clean
- I turn on
MEMMAN
V8 JavaScript for client and server
cd /usr/ports/www/node
make install clean
cd /usr/ports/www/nginx
make install clean
- I turn on
HTTP_GEOIP
,HTTP_GZIP_STATIC
,HTTP_GUNZIP_FILTER
,HTTP_PERL
,MAIL
,MAIL_SSL
,HTTP_AUTH_LDAP
,HTTP_AUTH_DIGEST
,HTTP_FANCYINDEX
,HTTP_PUSH
,HTTP_PUSH_STREAM
,HTTP_REDIS
,HTTP_RESPONSE
,HTTP_UPLOAD
,HTTP_UPLOAD_PROGRESS
(you can always install more or less depending on what your server needs) echo 'nginx_enable="YES"' >> /etc/rc.conf
mkdir /var/log/nginx
chmod g+w /var/log/nginx
1.2.8. Port: rbenv (https://github.com/sstephenson/rbenv)
cd /usr/ports/devel/rbenv
make install clean
- echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
- echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
1.2.9. Port: ruby-build (https://github.com/sstephenson/ruby-build)
cd /usr/ports/devel/ruby-build
make install clean
- You can leave RBENV checked; we already installed it.
- Execute the commands we placed into our
.bash_profile
,source ~/.bash_profile
(or. ~/.bash_profile
)
Let's install ruby at the base of our server. We'll be installing localized ruby versions later, (rbenv) but it's nice to have a global ruby present.
cd /usr/ports/lang/ruby21
make install clean
- You can pick whatever version you want, but you might as well go with the latest stable.
edit webserver jail get mac address fix router
sudo mkdir /var/run/unicorn
chmod g+w /var/run/unicorn
Next we're going to install the things we need to get our server hooked up and running. We'll start with Ruby.
First however, we need to do all of this inside the www
user, as it will be running nginx etc.
sudo su - www
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
. ~/.bash_profile
rbenv install 2.1.2
rbenv global 2.1.2
rbenv rehash
(test to see if Ruby runs - "ruby -v" - if not, run "exec $SHELL -l")
Let's get Bundler and Rails installed, as we'll need those to get a basic project up and running.
gem install bundler rails
gem install sqlite3 -- --with-sqlite3-dir=/usr/local
rbenv rehash
rails new sites/SITE_PROJECT_NAME
mv SITE_PROJECT_NAME current
mkdir SITE_PROJECT_NAME
mv current SITE_PROJECT_NAME
Partial credit goes to:
gem install unicorn
rbenv rehash
curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/unicorn.rb -o ~/sites/SITE_PROJECT_NAME/config/unicorn.rb
- Edit the unicorn.rb file that is now in your config directory for the rails project you made earlier.
vi ~/sites/SITE_PROJECT_NAME/config/unicorn.rb
- Set
site_name
to the name of your project (SITE_PROJECT_NAME, or whatever you called it) :wq!
(write, quit, because I said so)
We've already installed nginx, so now it's time to do a little setup.
Partial credit goes to:
- http://bsdbox.co/2014/01/12/emp-nginx-mysql-php-fpm-on-freebsd
- http://theflyingdeveloper.com/server-setup-ubuntu-nginx-unicorn-capistrano-postgres
cd /usr/local/etc/nginx
mkdir sites
mkdir conf.d
curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/options -o conf.d/options
curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/default.rails.site -o default.rails.site
curl -fsSL https://raw.github.com/TwilightCoders/FreeNAS-Rails-Setup/master/nginx.conf -o nginx.conf
cp default.rails.site sites/SITE_PROJECT_NAME.site
Now edit that file you just copied over and edit the following:
- Change
app_server
(line 1) toSITE_PROJECT_NAME_server
- Change the path on line 2 to match your socket path
- Change
server_name
to reflect the domain name you expect to use - Change the
root
path to match your project path - Finally, change the
proxy_pass
(near the bottom) to reflect the change you made in the first step
Alright! That wasn't too bad, now was it? Just a lot of coffee breaks waiting for things to compile/install.
Now the fun begins. From the 'www' user (sudo su - www
)
unicorn -c /home/www/sites/SITE_PROJECT_NAME/current/config/unicorn.rb -D
- now exit back out of user www
/usr/local/etc/rc.d/nginx start
- Direct your web browser to the IP/domain of your server.