Ubuntu + Nginx + php + swpan-fcgi build php network service
The environment of this article is Ubuntu 12. For other systems, you can check it yourself or communicate with me.
1. Install nginx
This step is relatively simple. Just sudo apt-get install nginx and you can install it. After installation, you need to set the nginx service port. Its default port is 80.
2. Set the nginx service port
The configuration file is in /etc/nginx/nginx.conf. The configuration file refers to sites-enabled/default. It can be configured as follows:
listen 8081 default_server; listen [::]:8081 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm;
where 8081 is the port I set, and the original one is 80. The directory corresponding to root is the directory corresponding to the website files, and can be set to a custom directory. index specifies the priority of the homepage.
In addition, configure the port of the php parser (php-cgi):
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: fastcgi_pass 127.0.0.1:3344; # # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
In my configuration file, the service port of php-cgi is set to 3344. Please pay attention when starting spawn-fcgi below.
Then restart nginx,
service nginx restart
3, install spawn-fcgi,
apt-get install spawn-fcgi
4, install php
apt-get install php5 php5-dev php5-cgi
5, start php-cgi, bind port 3344
sudo spawn-fcgi -a 0.0.0.0 -p 3344 -C 10 -u root -f /usr/bin/php-cgi
I forgot to add sudo before, It keeps getting errors when starting up, which is weird.
6. Test the php environment
Add the test.php file in /usr/share/nginx/html/. If the website directory is not this, add test.php in the corresponding directory. The content is as follows:
<?php phpinfo(); ?>
Enter URL: localhost:8081/test.php to see the result.
The above introduces Ubuntu + Nginx + php + swpan-fcgi to build a PHP network service, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide
