https://github.com/perfectlysoft/perfecttemplatefcgi
Perfect Empty Starter Project for FastCGI.
https://github.com/perfectlysoft/perfecttemplatefcgi
Last synced: 9 months ago
JSON representation
Perfect Empty Starter Project for FastCGI.
- Host: GitHub
- URL: https://github.com/perfectlysoft/perfecttemplatefcgi
- Owner: PerfectlySoft
- License: apache-2.0
- Created: 2016-06-27T23:27:31.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T17:31:19.000Z (over 8 years ago)
- Last Synced: 2025-10-14T00:39:38.295Z (9 months ago)
- Language: Swift
- Homepage: https://www.perfect.org
- Size: 20.5 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PerfectTemplateFCGI [简体中文](README.zh_CN.md)
Perfect Empty Starter FastCGI Project
This repository holds a blank Perfect project which can be cloned to serve as a starter for new work. It builds with Swift Package Manager and produces a FastCGI based server executable.
This server can run with any FastCGI enabled webserver over either UNIX socket files or TCP.
## Apache 24
To run with Apache 2.4, build and install the mod_perfect FastCGI module:
[Perfect-FastCGI-Apache2.4](https://github.com/PerfectlySoft/Perfect-FastCGI-Apache2.4)
## NGINX
Instructions for running with NGINX:
[NGINX](https://github.com/PerfectlySoft/Perfect/wiki/NGINX)
## Building & Running
The following will clone and build an empty starter project and launch the server.
```
git clone https://github.com/PerfectlySoft/PerfectTemplateFCGI.git
cd PerfectTemplateFCGI
swift build
.build/debug/PerfectTemplateFCGI
```
You should see the following output:
```
Starting FastCGI server on named pipe /Library/WebServer/VirtualHosts/perfect.fastcgi.sock
```
This means the server is running and waiting for connections.
## Starter Content
The template file contains a very simple "hello, world!" example. Note that you must install mod_perfect or otherwise configure your web server for FastCGI and change the namedPipe path such that it points one level above your server's document root.
```swift
import PerfectFastCGI
import PerfectHTTP
var routes = Routes()
routes.add(method: .get, uri: "/**") {
req, resp in
resp.appendBody(string: "Hello, world!Hello, world!")
resp.completed()
}
let server = FastCGIServer()
server.addRoutes(routes)
do {
// Launch the FastCGI server
// The path to the sock file must point to a directory one level up from the site's document root.
// The file must be called "perfect.fastcgi.sock"
// For example, the following path would suffice for a server whose document root is:
// /Library/WebServer/VirtualHosts/wwwroot/
try server.start(namedPipe: "/Library/WebServer/VirtualHosts/perfect.fastcgi.sock")
} catch {
print("Error thrown: \(error)")
}
```
## Further Information
For more information on the Perfect project, please visit [perfect.org](http://perfect.org).