日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

Linux下安装nginx, php, php-fpm并配置

發(fā)布時(shí)間:2023/12/9 linux 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux下安装nginx, php, php-fpm并配置 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

環(huán)境: Fedora20

?

目標(biāo): 在Fedora20上安裝好nginx服務(wù)器,并可正確解析php文件

?

1. 安裝:

yum makecache

yum install nginx php php-fpm

?

2. nginx的配置

按默認(rèn)配置(網(wǎng)站根目錄路徑:/usr/share/nginx/html),一般也是OK的。通過瀏覽器打開http://localhost來看,如果能正常顯示網(wǎng)頁(yè),就OK了。

還可以通過"nginx -t“ 來檢測(cè)

3. 修改,我將網(wǎng)站根目錄移到了/home/zcm/program/web下,導(dǎo)致出現(xiàn)了一系列的問題,現(xiàn)帖出完整配置(/etc/nginx/nginx.conf),以備將來對(duì)照

# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/#user nginx; user zcm; worker_processes 1;error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info;pid /run/nginx.pid;events {worker_connections 1024; }http {include /etc/nginx/mime.types;default_type application/octet-stream;log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;index index.html index.htm;# Load modular configuration files from the /etc/nginx/conf.d directory.# See http://nginx.org/en/docs/ngx_core_module.html#include# for more information.include /etc/nginx/conf.d/*.conf;server {listen 80 default_server;server_name localhost;root /home/zcm/program/web;#charset koi8-r;#access_log /var/log/nginx/host.access.log main;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / { }# redirect server error pages to the static page /40x.html#error_page 404 /404.html;location = /40x.html {}# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {#root /home/zcm/program/web;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}} }


4. 接下來才是重點(diǎn)

如果僅做了以上3步,訪問html等非php文件可能已經(jīng)沒問題了,但是要訪問.php文件,可能還不行,因?yàn)樯婕暗綑?quán)限問題。

4.1 需要給/home/zcm 加上rx權(quán)限:chmod +rx /home/zcm

4.2 對(duì)應(yīng)的.php文件要具有r權(quán)限.

?

5. 最后補(bǔ)充一點(diǎn)

Linux下的防火墻默認(rèn)阻擋了許多的協(xié)議和端口,如果在windows上ping不通或telnet不到指定端口,請(qǐng)一定要考慮下防火墻的問題。

?

完成以上配置,應(yīng)該就差不多了。如果實(shí)在是還有其他問題,可以仔細(xì)看下日志: /var/log/nginx/*

總結(jié)

以上是生活随笔為你收集整理的Linux下安装nginx, php, php-fpm并配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。