自己的生產(chǎn)環(huán)境:centos7,openresty,php,mysql
出現(xiàn)的問題:IP訪問是正常的,輸入ip/install顯示403 Forbidden,我給/usr/local/openresty/nginx/html目錄權(quán)限改為777還是不行,請(qǐng)問怎么解決這個(gè)問題呢?
剛剛發(fā)現(xiàn),50x.html也可以顯示,但是ip/install/index.php不能顯示.
如果我訪問my ip adress/install/index.php,結(jié)果是下載這個(gè)文件,請(qǐng)問怎么設(shè)置才能正確訪問index.php呢?
error.log 顯示:
2018/06/08 10:33:18 [error] 12018#12018: *334 directory index of "/usr/local/openresty/nginx/html/install/" is forbidden,
自己的nginx.conf 配置:
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
client_max_body_size 8m; #允許客戶端請(qǐng)求的最大單文件字節(jié)數(shù)
client_body_buffer_size 2m; #緩沖區(qū)代理緩沖用戶端請(qǐng)求的最大字節(jié)
#WAF
lua_shared_dict limit 50m; #防cc使用字典,大小50M
lua_shared_dict guard_dict 100m;
lua_shared_dict dict_captcha 70m;
lua_max_running_timers 1;
lua_package_path "/usr/local/openresty/nginx/conf/waf/?.lua";
init_by_lua_file "/usr/local/openresty/nginx/conf/waf/init.lua";
access_by_lua_file "/usr/local/openresty/nginx/conf/waf/access.lua";
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
listen [::]:80 default_server;
server_name my ip address;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.php;
}
location /phpmyadmin {
alias /usr/share/phpMyAdmin;
index index.php;
}
location ~ /phpmyadmin/.+\.php$ {
if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
set $valid_fastcgi_script_name $1;
}
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 這里新加的
# PHP 腳本請(qǐng)求全部轉(zhuǎn)發(fā)到 FastCGI處理. 使用FastCGI協(xié)議默認(rèn)配置.
# Fastcgi服務(wù)器和程序(PHP,Python)溝通的協(xié)議.
location ~ \.php$ {
# 設(shè)置監(jiān)聽端口
fastcgi_pass 127.0.0.1:9000;
# 設(shè)置nginx的默認(rèn)首頁(yè)文件(上面已經(jīng)設(shè)置過了,可以刪除)
fastcgi_index index.php;
# 設(shè)置腳本文件請(qǐng)求的路徑
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 引入fastcgi的配置文件
include fastcgi_params;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root 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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
server {
listen 443 ssl http2;
server_name my ip address;
charset utf-8;
ssl on;
default_type text/plain;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm index.php;
}
location ~ /phpmyadmin/.+\.php$ {
if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
set $valid_fastcgi_script_name $1;
}
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
}
location ~ \.php$ {
# 設(shè)置監(jiān)聽端口
fastcgi_pass 127.0.0.1:9000;
# 設(shè)置nginx的默認(rèn)首頁(yè)文件(上面已經(jīng)設(shè)置過了,可以刪除)
fastcgi_index index.php;
# 設(shè)置腳本文件請(qǐng)求的路徑
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 引入fastcgi的配置文件
include fastcgi_params;
}
}
}
你輸入 IP/install 出現(xiàn)403是因?yàn)槟愕?Nginx 配置沒有添加對(duì)應(yīng)的 location
# 其他的配置項(xiàng)
location /install {
root html; # 或者 root html/install;
index index.php;
# 其他的配置項(xiàng)
}
# 其他的配置項(xiàng)
如果你沒有這樣的 location,直接訪問 IP/install 會(huì)判定為在 'html' 目錄下查找 'install' 文件夾
*.php 文件訪問時(shí)變成自動(dòng)下載的原因一般都是 php-fpm 配置錯(cuò)誤,或者 php-fpm 沒有 正常啟動(dòng)監(jiān)聽
Nginx 配置文件,可以在 這里 下載(密碼:8qrk)。北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問,美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。