On this how to, we'll be using the simplest witty example: hello
I assumed you already had installed a CentOS 6.x minimal x86_64.
The Steps
- Login as a sudoer user.
- Append EPEL repository by creating the file /etc/yum.repos.d/epel.repo with the following content:
- Install required packages: nginx, witty and CentOS development kit:
- Go to Wt's examples directory and edit the CMakeLists.txt archive:
- Run CMake specifying FastCGI support & copy resulting binary to nginx document root:
- Create a new archive /etc/sysconfig/spawn-fcgi-hello.wt with the following content:
- Allow nginx to write at /var/spool/wt/run/:
- Launch hello app via spawn-fcgi:
- Create a new file /etc/nginx/conf.d/wt.conf w/ the following content:
- Restart nginx:
- Visit http://HOST:9091 and enjoy it!
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch failovermethod=priority enabled=1 gpgcheck=0
$ sudo yum install nginx $ sudo yum install wt $ sudo yum install fcgi $ sudo yum install spawn-fcgi $ sudo yum install wt-devel wt-examples # Only for development env $ sudo yum groupinstall "Development Tools" # Only for development env $ sudo yum install nano # Only for development env
$ cd /usr/lib64/Wt/examples/hello $ sudo nano CMakeLists.txtand replace
WT_ADD_EXAMPLE(hello.wt hello.C)by:
ADD_EXECUTABLE(hello.wt hello.C) TARGET_LINK_LIBRARIES(hello.wt ${EXAMPLES_CONNECTOR})
$ sudo rm -rf target $ sudo mkdir -p target $ cd target $ sudo cmake ../ -DEXAMPLES_CONNECTOR=wtfcgi -DCONNECTOR_FCGI=yes -DCONNECTOR_HTTP=no $ sudo make $ sudo cp -a hello.wt /usr/share/nginx/html/
FCGI_SOCKET=/var/run/hello.wt.socket FCGI_PROGRAM=/usr/share/nginx/html/hello.wt FCGI_USER=nginx FCGI_GROUP=nginx FCGI_EXTRA_OPTIONS="-M 0700" OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/hello.wt.socket.pid -- $FCGI_PROGRAM"
$ sudo chgrp nginx /var/spool/wt/run/ $ sudo chmod g+w /var/spool/wt/run/
$ source /etc/sysconfig/spawn-fcgi-hello.wt $ spawn-fcgi $OPTIONSnow the FastCGI is running and waiting.
server { listen 9091; server_name _; # by default relative to /usr/share/nginx/html location / { access_log /var/log/nginx/nginx-fastcgi-access.log; gzip off; # the full path /usr/share/nginx/html/hello.wt if ($uri !~ "^/hello.wt/$") { fastcgi_pass unix:/var/run/hello.wt.socket; } include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
$ service ngnix restart
Thank-you for posting this!
ReplyDeleteWhen I do "sudo make" in step 5, the first of many errors is "/usr/include/Wt/WApplication:22:25: error: boost/any.hpp: No such file or directory", but when I do "yum install boost" I get "Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.freedomvoice.com
* epel: linux.mirrors.es.net
* extras: mirrors.easynews.com
* updates: centos.mirrors.hoobly.com
Setting up Install Process
Package boost-1.41.0-11.el6_1.2.x86_64 already installed and latest version
Nothing to do"
Do you know what to do? Thanks again!
The former package includes /usr/include/boost/any.hpp. I forgot to include it in the installation steps.
DeleteJust run:
$ yum install boost-devel
Thanks for the feedback!