Nginx服务器配置PHP
来源:互联网 发布:量化交易算人工智能吗 编辑:程序博客网 时间:2024/06/09 12:47
Nginx服务器以fastcgi的方式来支持PHP,而通常Apache是以模块方式来运行PHP的。
ubuntu下安装PHP
以5.6版本为例,下载PHP源码,并解压得到php-5.6.2文件夹。
编译并安装php
然后以sudo方式make,make install即可。期间可能需要安装2到3个依赖包,apt-get安装即可。
安装完毕后/usr/local/php/sbin目录下应该有一个php-fpm,执行之。
表明PHP和fastcgi安装配置正确。
配置Nginx的nginx.conf文件
其位于/usr/local/nginx/conf/nginx.conf。先清空原有内容,再写入:
user nobody nobody;worker_processes 2;error_log /usr/local/nginx/logs/nginx_error.log crit;pid /usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile 51200;events{ use epoll; worker_connections 6000;}http{ include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096; log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]' '$host "$request_uri" $status' '"$http_referer" "$http_user_agent"'; sendfile on; tcp_nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k; request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path /usr/local/nginx/client_body_temp; proxy_temp_path /usr/local/nginx/proxy_temp; fastcgi_temp_path /usr/local/nginx/fastcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_comp_level 5; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml;server{ listen 80; server_name localhost; index index.html index.htm index.php; root /usr/local/nginx/html; location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; }}}
在/usr/local/nginx/html目录下加入一个php测试程序如:
启动Nginx
sudo ./nginx
浏览器访问
说明了Nginx服务器已成功调用了php-cgi。
响应头
服务器一行是Tengine,是Nginx的一种。服务端语言是php5.6.2。
phpinfo()
在测试php文件中加入phpinfo()
可见是以fastcgi方式运行php的。
Tengine服务器和php-fpm的启动
cgi方式运行的php中,php-fpm和nginx作为两个独立进程运行。启动不分先后顺序
阅读全文
0 0
- Nginx服务器配置PHP
- CentOS+Nginx+PHP+Mysql 服务器配置
- php+nginx做下载服务器配置
- Nginx 服务器隐藏 index.php 配置
- Nginx+php+http/https服务器配置
- ubuntu 11.04+nginx+mysql+php网站服务器配置
- APM Express(apache+php+mysql)以及nginx的服务器配置
- ubuntu11.10配置WEB服务器 Nginx + PHP + MySql
- CentOS 6.2 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- CentOS 6.2 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- 搭建LNMP(linux+nginx+mysql+php)服务器环境配置实例教程
- 【转】阿里云Linux redhat 服务器配置 nginx+ php + zend
- CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
- LNMP(linux+nginx+mysql+php)服务器环境配置
- LNMP(linux+nginx+mysql+php)服务器环境配置
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- LNMP(linux+nginx+mysql+php)服务器环境配置
- Column ' ' in where clause is ambiguous
- AndroidStudio建立完整JNI开发工程流程及Java通过JNI调用C函数
- IntelliJ IDEA Ultimate 2017激活方法
- Struts2+Spring3整合项目时遇到的一个问题
- 半编译半解释型语言
- Nginx服务器配置PHP
- poj3122 二分答案+贪心
- bzoj 3942: [Usaco2015 Feb]Censoring kmp算法
- _sqlite.so: undefined symbol: sqlite3_stmt_readonly 问题解决
- win7 X 64 tensorflow安装
- xcode 中使用freetype库
- C/C++语言基础 STL基础
- 1479 Problem C勤劳的ACgirls
- Tian Ji -- The Horse Racing HDU