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

TheSecretTokeEpingAphp-PowerEdwebSiterUnningSmoothlyShyunderHeavyLoadInVolvOLVOLVOLDEVERSALKEYSTRATICES:1)emplactopCodeCachingWithOpcachingWithOpCacheToreCescriptexecution Time,2)使用atabasequercachingCachingCachingWithRedataBasEndataBaseLeSendataBaseLoad,3)

你应该关心DependencyInjection(DI),因为它能让你的代码更清晰、更易维护。1)DI通过解耦类,使其更模块化,2)提高了测试的便捷性和代码的灵活性,3)使用DI容器可以管理复杂的依赖关系,但要注意性能影响和循环依赖问题,4)最佳实践是依赖于抽象接口,实现松散耦合。

是的,优化papplicationispossibleandessential.1)empartcachingingcachingusedapcutorediucedsatabaseload.2)优化的atabaseswithexing,高效Quereteries,and ConconnectionPooling.3)EnhanceCodeWithBuilt-unctions,避免使用,避免使用ingglobalalairaiables,并避免使用

theKeyStrategiestosiminificallyBoostphpapplicationPermenCeare:1)useOpCodeCachingLikeLikeLikeLikeLikeCacheToreDuceExecutiontime,2)优化AtabaseInteractionswithPreparedStateTemtStatementStatementSandProperIndexing,3)配置

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增强codemodocultion,可验证性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

选择DependencyInjection(DI)用于大型应用,ServiceLocator适合小型项目或原型。1)DI通过构造函数注入依赖,提高代码的测试性和模块化。2)ServiceLocator通过中心注册获取服务,方便但可能导致代码耦合度增加。

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)启用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替换loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

phpemailvalidation invoLvesthreesteps:1)格式化进行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3汉化版
中文版,非常好用

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境