nginx在fedora上的安装

更新时间:2023-05-29 05:45:15 阅读: 评论:0

nginxfedora上的安装
原理:
安装nginx没什么好说的,安装php-cig,lighthttpspawn-fcgi对其进行管理
1.yum仓库安装所需的软件
#yum install –y php php-cgi  nginx lighttpd-fastcgi
2.生成php-cgi的环境变量配置文件
# vim /etc/nginx/fastcgi_params
输入以下内容,并把该文件设置为相应属性,可以设置为0777

astcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $rver_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $rver_addr;
fastcgi_param SERVER_PORT $rver_port;
fastcgi_param SERVER_NAME $rver_name;
办公室主任竞聘演讲稿# PHP only, required if PHP was built with –enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
3.使用spawn-fcgi来控制php-fastcgi的进程

# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 200 -u nginx -g nginx -f /usr/bin/php-cgi

其中,a绑定的地址,p是端口 -CPHPCGI的进程数,一般根据自己服务器的内存大小设置,4G服务器,如果是纯WEBSERVER的,可以设置200左右
4.怎么开车起步增加rver
# vim /etc/f
rver{
  listen 80;
  rver_ ;#多个域名,用空格分开
  index index.html index.php index.htm;
  root /var/;
  location ~ .*.php$
  {
  include /etc/nginx/fastcgi_params;
  fastcgi_pass 127.0.0.1:9000;
  }
  }
一些更加详细的conf设置请参看nginx的维基,以及相关资料
一些提示:
yum安装的nginx,相关命令:rvie nginx start|stop|reload
nginx添加到系统启动项里:chkconfig nginx on

其中,个人介绍快手a绑定的地址,p是端口 -CPHPCGI的进程数,一般根据自己服务器的内存大小设置,4G服务器,如果是纯WEBSERVER的,可以设置200左右
4.增加rver
# vim /etc/f
rver{
  listen 80;
歌曲动寒川  rver_ ;#多个域名,用空格分开
  index index.html index.php index.htm;
  root /var/;
  location ~ .*.php$
  {
  include /etc/nginx/fastcgi_params;
  fastcgi_pass 127.0.0.1:9000;
  }
  }
一些更加详细的conf设置请参看nginx的维基,以及相关资料
一些提示:
yum安装的nginx,相关命令:rvie nginx start|stop|reload
nginx添加到系统启动项里:chkconfig nginx on

spawn-fcgi随系统自动启动。
vim /etc/rc.loal
在文件最后加上
# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 200 -u nginx -g nginx -f /usr/bin/php-cgi
焚烧秸秆如果phpssion不可用,一般是因为 /var/lib/php/ssion这个目录的对于nginx不可写,把它所有者改为nginx相应用户已经用户组
fedora16下安裝nginx + php-fpm
1、安装Nginx
直接运行如下命令:
yum install nginx
然后我们创建系统启动nginx的链接,并启动它:
systemctl enable nginx.rvice
六鳌古城systemctl start nginx.rvice
在您的Web服务器的IP地址或主机到浏览器(如192.168.0.100),你应该看到nginx的欢迎页面类型:
 
nginx-fedora
2、安装PHP5
需要安装一些列的模块,输入以下命令:
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
然后打开的/etc/php.ini并设定cgi.fix_pathinfo = 0
vi /etc/php.ini
[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to t PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, e the cgi specs. Setting
; this to 1 will cau PHP CGI to fix its paths to conform to the spec. A tting
; of zero caus PHP to behave as before. Default is 1. You should fix your scripts
局域网一键共享;
to u SCRIPT_FILENAME rather than PATH_TRANSLATED.
/manual/i.fix-pathinfo
cgi.fix_pathinfo=0
[...]
此外,以避免类似以下错误
[13-Nov-2011 22:13:16] PHP Warning: phpinfo(): It is not safe to rely on the system's timezone ttings. You are *required* to u the date.timezone tting or the date_default_timezone_t() function. In ca you ud any of tho methods and you are still getting this warning, you most likely misspelled the timezone identifier. We lected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /usr/share/nginx/html/info.php on line 2
… /var/log/php-fpm/www-error.log 中,当你调用一个PHP脚本在您的浏览器,你应该在/etc/php.ini文件中设置date.timezone
[...]
[Date]
;
Defines the default timezone ud by the date functions
/manual/figuration.php#ini.date.timezone
date.timezone = "Europe/Berlin"
[...]
你可以找到正确的时区为您的系统,运行命令:
cat /etc/sysconfig/clock
[root@rver1 ~]# cat /etc/sysconfig/clock
ZONE="Europe/Berlin"
[root@rver1 ~]#
下一步创建系统启动或者PHP-FPM并启动它:
systemctl enable php-fpm.rvice
systemctl start php-fpm.rvice
PHP-FPM是一个守护进程运行FastCGI服务器的端口9000
3nginx设置
输入命令:
vi /etc/f
配置是很容易理解。
你可以再以下网址了解更多配置信息:
/NginxFullExample
/NginxFullExample2
按照以下配置设置值:
[...]
worker_process 4;
[...]
keepalive_timeout 2;
[...]
虚拟主机是指在服务器{}容器。默认的虚拟主机是指在该文件 /etc/nginx/conf.f -让我们作如下修改:
[...]
rver {
listen 80;
x吧rver_name _;
#chart koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect rver error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass 127.0.0.1;
#}
# pass the PHP scripts to FastCGI rver listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
[...]
保存和重启服务:
systemctl reload nginx.rvice
现在你可以建立一个探针文件进行测试
4、建立 PHP-FPM 使用一个 Unix Socket
vi /etc/php-fpm.f
[...]
;listen = 127.0.0.1:9000
listen = /tmp/php5-fpm.sock
[...]
重启PHP-FPM
systemctl restart php-fpm.rvice
配置文件:
vi /etc/nginx/conf.f
配置内容如下:
[...]
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
[...]
重启Nginx:
systemctl reload nginx.rvice

本文发布于:2023-05-29 05:45:15,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/804551.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:设置   系统   文件   配置   命令   安装   服务器   浏览器
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图