Using (Fast)CGI for non-PHP websites: Difference between revisions
From ULYSSIS documentation
| Rockinroel (talk | contribs)  (Created page with "You're not stuck with PHP if you want to make a dynamic website. You can use all sorts of frameworks and programming languages with ULYSSIS, as long as it has CGI or FastCGI s...") | Rockinroel (talk | contribs)  | ||
| Line 10: | Line 10: | ||
| We use Apache's [http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html mod_fcgid] to provide support for FastCGI. | We use Apache's [http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html mod_fcgid] to provide support for FastCGI. | ||
| ===Example: Django=== | |||
| If you want to make a website using [https://www.djangoproject.com/ Django], we recommend that you use a [http://virtualenv.readthedocs.org/ virtualenv]. This tool is already preinstalled on our shell servers. | |||
| You can use the following steps to get up and running with Django at ULYSSIS: | |||
| <ol> | |||
| <li>[[Accessing shell servers over SSH|Log in to a shell server]]</li> | |||
| <li>Create a new virtualenv, you can create one in <tt>~/.venv</tt>, for example: | |||
| <pre>virtualenv ~/.venv</pre> | |||
| </li> | |||
| <li>Activate this virtualenv: | |||
| <pre>. ~/.venv/bin/activate</pre> | |||
| </li> | |||
| <li> | |||
| Install Django inside of this virtualenv: | |||
| <pre>pip install django</pre> | |||
| </li> | |||
| <li> | |||
| Create a new Django project: | |||
| <pre>django-admin.py startproject mysite</pre> | |||
| </li> | |||
| <li> | |||
| Install flup for FastCGI: | |||
| <pre>pip install flup</pre> | |||
| </li> | |||
| <li> | |||
| Put an <tt>.htaccess</tt> file in your site's directory, e.g. the <tt>www</tt> folder: | |||
| <pre> | |||
| Options +ExecCGI | |||
| AddHandler fcgid-script .fcgi | |||
| RewriteEngine On | |||
| RewriteCond %{REQUEST_FILENAME} !-f | |||
| RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]</pre> | |||
| </li> | |||
| <li> | |||
| Create the starter script (replace ''user'' with org if you are an organization, and ''username'' with your ULYSSIS username): | |||
| <pre>#!/home/user/username/.venv/bin/python | |||
| import sys, os | |||
| sys.path.insert(0, '/home/user/username/mysite') | |||
| os.chdir('/home/user/username/mysite') | |||
| os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' | |||
| from django.core.servers.fastcgi import runfastcgi | |||
| runfastcgi(method="threaded", daemonize="false") | |||
| </pre> | |||
| </li> | |||
| </ol> | |||
Revision as of 17:48, 30 August 2014
You're not stuck with PHP if you want to make a dynamic website. You can use all sorts of frameworks and programming languages with ULYSSIS, as long as it has CGI or FastCGI support.
If you want to use a certain programming language or framework, and you can't get it to work, don't hesitate to contact us at ulyssis@ulyssis.org.
CGI
CGI is a very easy and simple way to create a dynamic website. We use Apache's mod_cgid to provide support for CGI.
FastCGI
We use Apache's mod_fcgid to provide support for FastCGI.
Example: Django
If you want to make a website using Django, we recommend that you use a virtualenv. This tool is already preinstalled on our shell servers.
You can use the following steps to get up and running with Django at ULYSSIS:
- Log in to a shell server
- Create a new virtualenv, you can create one in ~/.venv, for example:
virtualenv ~/.venv 
- Activate this virtualenv:
. ~/.venv/bin/activate 
- 
Install Django inside of this virtualenv:
pip install django 
- 
Create a new Django project:
django-admin.py startproject mysite 
- 
Install flup for FastCGI:
pip install flup 
- 
Put an .htaccess file in your site's directory, e.g. the www folder:
Options +ExecCGI AddHandler fcgid-script .fcgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
- 
Create the starter script (replace user with org if you are an organization, and username with your ULYSSIS username):
#!/home/user/username/.venv/bin/python import sys, os sys.path.insert(0, '/home/user/username/mysite') os.chdir('/home/user/username/mysite') os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' from django.core.servers.fastcgi import runfastcgi runfastcgi(method="threaded", daemonize="false")
