CentOS中安装Nginx+Php搭建Twip

Introduction

之前wordpress按照Guides无脑配置Apache完成,装好nginx只做了转发。搭建Twip的时候发现需要配合php-fpm

文章基本参考
Digitalocean:How To Install LEMP stack On CentOS 7

Prerequisites

Note about SELinux:

If you run into issues with Nginx not running, make sure the SELinux context of your Nginx configuration files is correct or change the SELinux mode to permissive or disabled.

Step

  1. 安装Nginx
    sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    sudo yum install nginx
    开启服务
    sudo systemctl start nginx.service

  2. 安装php环境
    sudo yum install php php-mysql php-fpm
    配置php-fpm www.conf
    sudo vim /etc/php-fpm.d/www.conf
    找到并修改listen
    listen = /var/run/php-fpm/php-fpm.sock
    开启服务
    sudo systemctl start php-fpm

  3. 配置nginx-twip

server {
    listen      80;
    listen      443 ssl;
    server_name twip.example.com;
    ssl_certificate      /root/csr/startsslxxx.crt;
    ssl_certificate_key  /root/csr/xxxpri.key;
    ssl_prefer_server_ciphers   on;
    client_max_body_size 8m;
    gzip     on;
    index    index.html index.php;
    root   /var/www;
    location /twip/oauth {
        deny all;
    }
    location /twip/ {
        try_files $uri /twip/index.php?$args;
    }
    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Test PHP Processing on your Web Server

在网站根目录添加info.php

twip的配置参考

另一份Twip4搭建Twitter API教程

你可能感兴趣的:(CentOS中安装Nginx+Php搭建Twip)