centos安装nginx+php-fpm
好久没装过PHP环境了,好久没有手动配置LNMP环境了,今天就让我头疼了一把!
不过随着时间的推移,yum的源里越来越多的库可以直接使用了,现在自己在配置nginx和php环境就不再需要源码编译,也不再需要往yum中添加啥源了,直接就可以通过下面的命令完成安装:
yum install -y nginx php php-fpm
若系统之前yum安装过php,可以先卸载了:
yum remove httpd* php*
安装完毕后,需要稍微修改一下配置文件来完成最后的工作,php-fpm需要修改一下权限:
vi /etc/php-fpm.d/www.conf
将 Unix user/group of processes改成你os对应的设置,例如:
user = www group = www
然后需要开启nginx对应的php配置项:
vi /etc/nginx/conf.d/default.conf
开启下面这部分配置:
location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }
一切就绪,就可以分别开启对应服务了:
/etc/init.d/php-fpm restart /etc/init.d/nginx restart
nginx File not found 错误
这个时候如果你访问本地的nginx服务,如果看到了”File not found”错误提醒,原因多半是: php-fpm进程找不到SCRIPT_FILENAME配置的要执行的.php文件。
由于默认nginx将 root参数放在了 location内部,所以你得注意一下对应设置的文件目录是否正确,或者推荐你将 root参数从 location中移到 server中,这样所有的子 location将使用统一的web根目录。
此外,为了避免一些php cms系统的默认行为,你还是最好将 index参数里增加 index.php,来适配系统的默认首页匹配规范,避免不必要的麻烦。

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



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...
