How do I install and configure a ngnix FastCGI php5 HTTP / web server under Red Hat / RHEL / Fedora / CentOS Linux?
Nginx (engine x) is an HTTP(S) server, reverse proxy and IMAP/POP3 proxy server written by Igor Sysoev. It is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
Step # 1: Enable EPEL repo
ngnix is not included in the base system. Turn on EPEL repo to install nginx stable release:# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/$(uname -m)/epel-release-5-3.noarch.rpm
Step # 2: Install ngnix
Type the following command at a shell prompt:# yum install nginx
Sample output:
Loaded plugins: downloadonly, fastestmirror, priorities, protectbase Loading mirror speeds from cached hostfile * epel: archive.linux.duke.edu * base: ftp.linux.ncsu.edu * updates: centos.mirror.nac.net * addons: mirror.cs.vt.edu * extras: centos.mirror.nac.net 0 packages excluded due to repository protections Setting up Install Process Parsing package install arguments Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 0:0.6.34-1.el5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================================== Installing: nginx x86_64 0.6.34-1.el5 epel 319 k Transaction Summary ============================================================================================================================================================== Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total size: 319 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : nginx [1/1] Installed: nginx.x86_64 0:0.6.34-1.el5 Complete!
nginx configuration file
- Default config file: /etc/nginx/nginx.conf
- Default SSL config file: /etc/nginx/conf.d/ssl.conf
- Default virtual hosting config file: /etc/nginx/conf.d/virtual.conf
- Default documentroot: /usr/share/nginx/html
Configure PHP As FastCGI
Type the following to install php5 with other modules:# yum install php-pear-Net-Socket php-pear php-common php-gd php-devel php php-mbstring php-pear-Mail php-cli php-imap php-snmp php-pdo php-xml php-pear-Auth-SASL php-ldap php-pear-Net-SMTP php-mysql
Install spawn-fcgi simple program for spawning FastCGI processes
Type the following command:# yum install spawn-fcgi
Next, download spawn-fcgi init.d shell script:# wget http://bash.cyberciti.biz/dl/419.sh.zip
# unzip 419.sh.zip
# mv 419.sh /etc/init.d/php_cgi
# chmod +x /etc/init.d/php_cgi
Start php app server, enter:# /etc/init.d/php_cgi start
# netstat -tulpn | grep :9000
Sample output:
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14294/php-cgi
By default php server listens on 127.0.0.1:9000 port. Finally, update /etc/nginx/nginx.conf as follows:# vi /etc/nginx/nginx.conf
Modify / append as follows:
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; }
Save and close the file. Restart nginx:# service nginx restart
Create /usr/share/nginx/html/test.php as follows:
<?php phpinfo(); ?>
相关推荐
LVS & Nginx负载均衡优缺点对比
linux&nginx;笔试题大全,按知识点划分,详细记录了所有的笔试题。各位下载做一做吧
2. **RTMP Support in Nginx**:通过安装和配置nginx-rtmp-module,Nginx可以作为RTMP服务器接收和分发流媒体内容。RTMP协议适合实时内容,如直播事件,因为它的延迟低。Nginx可以接受来自摄像机、编码器或其他RTMP...
docker-php-nginx 基于 phusion/baseimage-docker 的 Dockerized php & nginx
【FastDFS&Nginx】基于CentOS 7.9 的安装所需的安装包 参考安装教程:https://blog.csdn.net/HXBest/article/details/106432959 如果参考以上教程,安装包版本最好与教程一致!
Linux Docker & Nginx 环境安装搭建 本文档将指导您如何在 Linux 系统上安装和配置 Docker 和 Nginx 环境。 Docker 安装 在开始安装 Docker 之前,我们需要确保 Linux 系统的内核版本高于 3.10。我们可以使用 `...
十、前后端分离通用权限系统(10)gansu-system-front(10)&nginx.zip
- 安装 Nginx 通常通过 `yum install nginx` 或者源码编译。 - 配置 Nginx,编辑 `nginx.conf` 文件,设置反向代理规则。 - 例如,反向代理到 Tomcat 服务器,可以在 `http` 部分添加一个 `server` 块,设置监听...
5. **配置Nginx**:在后端服务器上安装Nginx,通过`yum install nginx`或`apt-get install nginx`。配置Nginx的反向代理规则,将接收到的请求转发到内部服务。 6. **健康检查**:在Keepalived配置中,可以添加脚本...
1、最新版 nginx-http-flv-module(windows可执行程序,含nginx 1.19.3,http-flv-module:1.2.7) 2、内含说明文档,请下载查看。 3、请勿放置于中文路径下,否则无法启动
在本文中,我们将深入探讨如何在CentOS操作系统上编译安装Tengine以及配置Nginx以支持自启动脚本。Tengine是由淘宝网基于Nginx开发的一个高性能、高可用的Web服务器,它包含了Nginx的核心功能以及一系列增强特性。 ...
1、最新版 nginx-http-flv-module(linux可执行程序,含nginx 1.19.3,http-flv-module:1.2.7) 2、内含说明文档,请下载查看。 3、请勿放置于中文路径下,否则无法启动 4、sbin/nginx -c conf/nginx.conf
在Windows环境下,为了高效地管理和运行Nginx与PHP-CGI服务,我们可以创建批处理脚本来实现一键启动。下面将详细介绍如何配置和使用批处理文件来启动这两个关键组件。 首先,Nginx是一款轻量级的Web服务器,常用于...
本文主要探讨了在安装完成后打开Nginx默认网页时显示"Welcome to nginx on Fedora!",而不是预期的"Welcome to nginx!",同时在`/etc/nginx/conf.d`目录下找不到`default.conf`文件的情况。这种情况通常是因为CentOS...
- 安装命令可能为:`sudo apt-get install nginx` 或 `sudo yum install nginx`。 3. **配置Nginx支持CGI** - 编辑Nginx配置文件,通常位于`/etc/nginx/nginx.conf`或`/etc/nginx/sites-available/default`。 - ...
nginx一键安装包install_nginx.sh
sudo apt-get install nginx ``` 对于CentOS或Fedora,可以使用Yum: ```bash sudo yum install epel-release sudo yum install nginx ``` 如果想要安装最新版本的Nginx,或者需要自定义配置,可以从Nginx官方...
本安装文件修改了源码网的“CentOS 集成linux+php-cgi+nginx+mysql安装包“里面的部分文件,主要是修改了install.sh内的几个错误位置。目前我测试在centos 5.4下,安装一切正常! 使用这个安装之前请一定看一下本...
本安装文件修改了源码网的“CentOS 集成linux+php-cgi+nginx+mysql安装包“里面的部分文件,主要是修改了install.sh内的几个错误位置。目前我测试在centos 5.4下,安装一切正常! 使用这个安装之前请一定看一下本...
"install-nginx.tar.gz"这个压缩包文件包含了进行Nginx独立安装和部署所需的所有步骤和配置文件,旨在帮助用户快速解决依赖问题并启用自定义配置。 1. **系统需求与准备** 在开始安装前,确保你的操作系统是基于...