CentOS 6 部署 Nginx + PHP5 服务器
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
安装 Nginx
添加 nginx 的 YUM 库配置文件 /etc/yum.repos.d/nginx.repo,
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
root 用户执行:
# yum install nginx
安装 PHP 及重要插件 php-fpm
root 用户执行:
# yum install php-fpm
将会安装好 php-fpm 以及 php 本身在内的其他依赖。
配置、启动 php-fpm
配置 /etc/php.ini,设置 cgi.fix_pathinfo=0
启动 php-fpm 并放置后台运行
php-fpm -D
停掉 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
或者通过 service 命令执行
service php-fpm stopservice php-fpm start
配置、启动 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; } }}
启动 Nginx 服务器
$ nginx
或者通过 service 命令执行:
service nginx stopservice nginx start
如果运行时修改了配置文件,可以通过 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

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

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

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

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-

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

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' =>

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.

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

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
