Detailed explanation of how to build phalcon environment under nginx server on centos7 system

Detailed explanation of how to build phalcon environment under nginx server on centos7 system

This article describes how to build a phalcon environment under the nginx server of the centos7 system. Share with you for your reference, the details are as follows:

Previously, we used Apache server, but the response rate could only reach 2000 per second. I heard that nginx can easily reach 10,000.

So let’s try nginx.

Phalcon's official website has examples of nginx rewrite rules, but they are inconsistent with Apache's, which made me confused for a long time.

1. Add nginx source

vi /etc/yum.repos.d/nginx.repo

 [nginx]
   name=nginx-repo
   baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
   gpgcheck=0
   enabled=1

2. Modify the configuration of nginx

vi /etc/nginx/conf.d/default.conf
server {
  listen 80;
  server_name localhost.dev;
  index index.php index.html index.htm;
  root /var/www/html;
  location / {
    root /var/www/html; #phalcon official website is the public directory. If you use this directory, it will be different from the Apache configuration index index.php index.html index.htm;
    # If the file exists, return the file directly if (-f $request_filename) {
      break;
    }
    # If it does not exist, redirect to public/index.php
    if (!-e $request_filename) {
      rewrite ^(.+)$ /public/index.php?_url=$1 last;
      break;
    }
  }
  location ~ \.php$ {
      try_files $uri =404;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
  }
  location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
    root /var/www/html/public;
  }
  location ~ /\.ht {
    deny all;
  }
}

3. Configuration of php-fpm

vi /etc/php-fpm.d/www.conf

Modify to user and user group

; RPM: apache Chooses to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

4. User group modification

chown -R nginx:nginx /var/lib/php/session/
chown -R nginx:nginx /var/www/html/

Restart nginx and php-fpm.

systemctl restart nginx
systemctl restart php-fpm

Further optimization and waiting for the next situation

I hope this article will be helpful for your centos server operations.

You may also be interested in:
  • Detailed tutorial on building Gitlab server on CentOS8.1
  • Implementation steps for building a local web server on Centos8
  • How to build mysql master-slave server on centos7 (graphic tutorial)
  • Detailed explanation of building Nginx website server based on centos7 (including configuration of virtual web host)
  • CentOS 7.2 builds nginx web server to deploy uniapp project
  • Tutorial on building a master-slave DNS server in Centos7
  • Install and build a server environment of PHP+Apache+MySQL on CentOS
  • A concise tutorial on setting up a PHP server environment on CentOS
  • Centos builds chrony time synchronization server process diagram

<<:  MySQL 8.0.13 free installation version configuration tutorial under Windows environment

>>:  In-depth explanation of MySQL user account management and permission management

Recommend

Practical method of deleting a row in a MySql table

First, you need to determine which fields or fiel...

Pure CSS3 mind map style example

Mind Map He probably looks like this: Most of the...

Examples of using Docker and Docker-Compose

Docker is an open source container engine that he...

Linux system MySQL8.0.19 quick installation and configuration tutorial diagram

Table of contents 1. Environment Introduction 2. ...

js to realize automatic lock screen function

1. Usage scenarios There is such a requirement, s...

Use of kubernetes YAML files

Table of contents 01 Introduction to YAML files Y...

MySQL 5.7.18 version free installation configuration tutorial

MySQL is divided into installation version and fr...

A designer complains about Hammer's official website again

Last year, the open letter was a huge hit, even a...

The combination and difference between ENTRYPOINT and CMD in dockerfile

In the previous article [Detailed explanation of ...

Vue multi-page configuration details

Table of contents 1. The difference between multi...

Example of how to set up a multi-column equal height layout with CSS

Initially, multiple columns have different conten...

Detailed explanation of the new array methods in JavaScript es6

Table of contents 1. forEach() 2. arr.filter() 3....

Summary of common commands for Ubuntu servers

Most of the commands below need to be entered in ...

mysql5.7.19 winx64 decompressed version installation and configuration tutorial

Recorded the installation tutorial of mysql 5.7.1...