wnmp的php会自动挂掉,初探wnmp php

wnmp是windows下,Nginx、MySQL、PHP的环境集成包。新手用该集成包学习PHP,搭建自己的本地服务器十分便利。原理性的东西我还需要进一步学习,现在先简单看一下如何完成初始的环境构建。

首先进行本地服务器地址路径设置:

打开安装目录下的conf文件,在其中找到nginx.conf。初始配置文件如下:

worker_processes 1;

error_log logs/error.log;

pid logs/nginx.pid;

events {

# Max value 16384

worker_connections 8192;

# Accept multiple connections

multi_accept on;

}

# Settings that affect all server blocks

http {

include php_processes.conf;

include mime.types;

default_type application/octet-stream;

access_log logs/access.log;

sendfile on;

keepalive_timeout 65;

ssl_session_timeout 10m;

ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3;

ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS;

ssl_prefer_server_ciphers on;

gzip on;

# http server

# Begin HTTP Server

server {

listen 80; # IPv4

server_name localhost;

## Parametrization using hostname of access and log filenames.

access_log logs/localhost_access.log;

error_log logs/localhost_error.log;

## Root and index files.

root html;

index index.php index.html index.htm;

## If no favicon exists return a 204 (no content error).

location = /favicon.ico {

try_files $uri =204;

log_not_found off;

access_log off;

}

## Don't log robots.txt requests.

location = /robots.txt {

allow all;

log_not_found off;

access_log off;

}

## Try the requested URI as files before handling it to PHP.

location / {

## Regular PHP processing.

location ~ \.php$ {

try_files $uri =404;

fastcgi_pass php_processes;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

## Static files

location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {

expires max;

log_not_found off;

## No need to bleed constant updates. Send the all shebang in one

## fell swoop.

tcp_nodelay off;

## Set the OS file cache.

open_file_cache max=1000 inactive=120s;

open_file_cache_valid 45s;

open_file_cache_min_uses 2;

open_file_cache_errors off;

}

## Keep a tab on the 'big' static files.

location ~* ^.+\.(?:ogg|pdf|pptx?)$ {

expires 30d;

## No need to bleed constant updates. Send the all shebang in one

## fell swoop.

tcp_nodelay off;

}

} # / location

}

# End HTTP Server

# Begin HTTPS Server

server {

listen 443 http2 ssl;

server_name localhost;

ssl_certificate cert.pem;

ssl_certificate_key key.pem;

ssl_session_cache shared:SSL:10m;

ssl_session_timeout 10m;

## Parametrization using hostname of access and log filenames.

access_log logs/localhost_access.log;

error_log logs/localhost_error.log;

## Root and index files.

root html;

index index.php index.html index.htm;

## If no favicon exists return a 204 (no content error).

location = /favicon.ico {

try_files $uri =204;

log_not_found off;

access_log off;

}

## Don't log robots.txt requests.

location = /robots.txt {

allow all;

log_not_found off;

access_log off;

}

## Try the requested URI as files before handling it to PHP.

location / {

## Regular PHP processing.

location ~ \.php$ {

try_files $uri =404;

fastcgi_pass php_processes;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

## Static files are served directly.

location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {

expires max;

log_not_found off;

## No need to bleed constant updates. Send the all shebang in one

## fell swoop.

tcp_nodelay off;

## Set the OS file cache.

open_file_cache max=1000 inactive=120s;

open_file_cache_valid 45s;

open_file_cache_min_uses 2;

open_file_cache_errors off;

}

## Keep a tab on the 'big' static files.

location ~* ^.+\.(?:ogg|pdf|pptx?)$ {

expires 30d;

## No need to bleed constant updates. Send the all shebang in one

## fell swoop.

tcp_nodelay off;

}

} # / location

} # End HTTPS Server

}

改变http和https中的root下的路径为你所需要搭建本地服务器的路径,默认为html即可,其它内容还得继续研究,先跑起来再说~

此时,打开wnmp,start all之后,在浏览器输入localhost,看到这个页面,就代表已经安装成功:

80b9103ad51e

然后,自己尝试搭建第一个网页:

80b9103ad51e

1、简单描述下web 服务器、PHP、数据库、浏览器是如何实现动态网站的?

要了解动态网站,首先我们得知道一个用户获取静态网页的过程:

80b9103ad51e

首先用户在浏览器输入URL后,通过DNS来获取IP地址以找到相对应服务器。

服务器根据用户的需求,即URL地址上所表达的东西,返回给浏览器一个静态的HTML文件。

最后浏览器对该HTML文件进行渲染展现给用户。

如果网页是一成不变的还好,但是涉及到表单提交时,静态网站就远不能满足用户的需求了:

80b9103ad51e

在静态网页,用户表单填写无法与服务器进行交互,只能将数据填写完成之后,以邮件发送的形式将数据提交,且无法检查自己填写的信息,这么麻烦的操作催生了动态网页的形成。

80b9103ad51e

首先用户按照静态页面的方式获取了一个页面;

当用户在该静态页面上发送请求时,向服务器提交了一个php脚本的地址;

服务器通过php对用户的需求进行处理:可以发送邮件,也可以通过数据库(php一般对应的MySQL)增删改查来存储数据;

服务器将运行过php转换为html文件,并返还给浏览器;

浏览器对html文件进行渲染,呈现在用户面前。

2、常见的web服务器有哪些?

最常见的WEB服务器是:Apache、Nginx、IIS;

此外还有:Tomcat和Zeus。

3、打开浏览器,在地址栏输入 http://jirengu.com 页面展现了饥人谷官网的信息,整个过程发生了什么?(饥人谷官网后台语言 php,web服务器 nginx,数据库 mysql)

互联网通过DNS将URL翻译成IP地址(如果先前访问过该网站,通过浏览器->操作系统->路由器->运营商->根,层层寻找DNS缓存,一定会得到!);

若用户以前登录过饥人谷官网,随着URL地址传过来的还有一个cookie。

此饥人谷的服务器nginx得到响应,根据用户的需求,通过PHP进行处理,如果涉及到用户登录以及数据请求或提交,还将与数据库MySQL进行交互,服务器将返回一个静态的html文档。

通过TCP/IP协议三次握手,确定网络正常,将静态html文档送至客户端(浏览器)。

浏览器对html进行渲染,将饥人谷官网呈现给用户。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值