Table of Contents
安装 一些必要的 YUM 库
安装 Nginx
安装 PHP 及重要插件 php-fpm
配置、启动 php-fpm
配置、启动 Nginx
FAQ
如何解决 “NO INPUT FILE SPECIFIED” 的问题,当我们安装 PHP 和 NGINX 的时候
Home Backend Development PHP Tutorial CentOS 6 部署 Nginx + PHP5 服务器

CentOS 6 部署 Nginx + PHP5 服务器

Jun 23, 2016 pm 01:38 PM

CentOS 6 部署 Nginx + PHP5 Web服务器

CetnOS 6 (64位) 操作系统上部署Nginx and PHP5服务器。这个过程通过 yum 命令进行RPM包安装。

可以参考 PHP 官方文档。

安装 一些必要的 YUM 库

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Copy after login

安装 Nginx

添加 nginx 的 YUM 库配置文件 /etc/yum.repos.d/nginx.repo

[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
Copy after login

root 用户执行:

# yum install nginx
Copy after login

安装 PHP 及重要插件 php-fpm

root 用户执行:

# yum install php-fpm
Copy after login

将会安装好 php-fpm 以及 php 本身在内的其他依赖。

配置、启动 php-fpm

配置 /etc/php.ini,设置 cgi.fix_pathinfo=0

启动 php-fpm 并放置后台运行

php-fpm -D
Copy after login

停掉 php-fpm 的方法

root@acx-xiwang:/etc# ps -ef | grep php-fpmroot     31591     1  0 14:09 ?        00:00:00 php-fpm: master process (/etc/php-fpm.conf)apache   31592 31591  0 14:09 ?        00:00:00 php-fpm: pool wwwapache   31593 31591  0 14:09 ?        00:00:00 php-fpm: pool wwwapache   31594 31591  0 14:09 ?        00:00:00 php-fpm: pool wwwapache   31595 31591  0 14:09 ?        00:00:00 php-fpm: pool wwwapache   31596 31591  0 14:09 ?        00:00:00 php-fpm: pool wwwroot     31914 31878  0 14:32 pts/1    00:00:00 grep --color php-fpmroot@acx-xiwang:/etc# kill -s SIGINT 31591
Copy after login

或者通过 service 命令执行

service php-fpm stopservice php-fpm start
Copy after login

配置、启动 Nginx

直接分享我的配置 /etc/nginx/nginx.conf

user xiwang;events {}http {    include     /etc/nginx/mime.types;    server {        root    /home/xiwang/opt/www;        location / {            index   index.html index.htm index.php;        }        error_page  404              /404.html;        location ~* \.php$ {            fastcgi_index   index.php;            fastcgi_pass    127.0.0.1:9000;            #fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;            fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;            include         fastcgi_params;        }    }}
Copy after login

启动 Nginx 服务器

$ nginx
Copy after login

或者通过 service 命令执行:

service nginx stopservice nginx start
Copy after login

如果运行时修改了配置文件,可以通过 nginx -s reload 来使配置文件生效。

FAQ

如何解决 “NO INPUT FILE SPECIFIED” 的问题,当我们安装 PHP 和 NGINX 的时候

文章: 英文原版

检查 php 文件是否拥有写权限,它的父目录都有执行权限

chmod a+x /home/xiwang/opt            #<-- container folder should be granted execute permissionchmod a+x /home/xiwang/opt/www        #<-- container folder should be granted execute permissionchmod a+w /home/xiwang/opt/www/*.php  #<-- .php file should be granted write permission
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram API Introduction to the Instagram API Mar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation Survey Announcement of 2025 PHP Situation Survey Mar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles