-
Notifications
You must be signed in to change notification settings - Fork 3
Setup Web Server on Ubuntu
Minjie Zha edited this page Oct 14, 2013
·
19 revisions
This wiki describes the steps about how to setup and configure the SearchPocket web server on a Ubuntu server.
- Create a normal user.
# adduser mzha --home /home/mzha --shell /bin/bash- Add the user to sudoers.
# adduser mzha sudo- Install MySQL.
$ sudo apt-get install mysql-server- Start MySQL server at boot time:
$ sudo update-rc.d mysql defaultsTo remove it:
$ sudo update-rc.d mysql remove- Set encoding to UTF-8 in
/etc/mysql/my.conf.
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
- Restart MySQL and login to it. Make sure the encodings are correct by running:
mysql> show variables like 'char%';and
mysql> show variables like 'collation%';- Install compilers and other build tools.
$ sudo apt-get install build-essential- Install MySQL development libs.
$ sudo apt-get install libmysqlclient-dev- Downlaod the latest sphinx release.
$ wget http://sphinxsearch.com/files/sphinx-2.1.2-release.tar.gz- Extract the file, go into its folder, and run the following commands to build and install sphinx:
$ ./configure --with-mysql
$ make
$ sudo make install- Follow Quick Sphinx usage tour to make sure it is correctly installed.
- Run the following commands to install ruby 2.0.0 in Ubuntu:
$ sudo apt-get update
$ sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
$ cd /tmp
$ wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
$ tar -xvzf ruby-2.0.0-p247.tar.gz
$ cd ruby-2.0.0-p247/
$ ./configure --prefix=/usr/local
$ make
$ make install- Install bundler.
$ sudo gem install bundler- Install Git:
$ sudo apt-get install git- Clone search_pocket project from github.
$ git clone https://github.com/magic003/search_pocket.git- Go to
search_pocketand install the dependencies.
$ sudo bundle- Create database/user for both
developmentandproductionenvironments.
$ mysql -uroot -p
mysql> create database spdev;
mysql> grant all on spdev.* to 'spdev'@'localhost' identified by '<password>';-
Change configurations in
config/config.ym. -
Change configurations in
config/sphinx.conf. -
Run sequel migration to setup databases.
$ sequel -m db/migrations mysql2://spdev:<password>@localhost/spdev- Start application in
developmentmode, to make sure it is working.
$ ruby search_pocket_app.rb- Install nginx and start it.
$ sudo apt-get install nginx
$ sudo /etc/init.d/nginx start- Create
nginxuser andwebgroup.
$ sudo useradd -s /sbin/nologin -r nginx
$ sudo groupadd web
$ sudo usermod -a -G web nginx
$ sudo usermod -a -G web mzha- Create
/var/www.
$ sudo mkdir /var/www
$ sudo chgrp -R web /var/www # set /var/www owner group to "web"
$ sudo chmod -R 775 /var/www # group write permission- Edit
/etc/nginx/nginx.confand/etc/nginx/sites-enabled/default.
user nginx web;
worker_processes 1;
root: '/var/www';
- Install unicorn.
$ sudo gem install unicorn- Go to
/var/www/search_pocket, get unicorn conf and change it.
$ curl -o config/unicorn.rb https://raw.github.com/defunkt/unicorn/master/examples/unicorn.conf.rb- Start unicorn.
$ unicorn -c config/unicorn.rb -E development -D-
Add
spto/etc/nginx/sites-enabled. -
Restart nginx.
$ sudo /etc/init.d/nginx restartRefer to: