linux服务器下LNMP安装与配置方法
发布时间:2023-02-20 09:57:06 所属栏目:LNMP 来源:互联网
导读:注意:关闭rpm默认安装的apache和mysql 1.准备php函数的rpm包 yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2
# -e 是否存在 rewrite ^/ http://www.sohu.com/ permanent; # ^/ 域名以/开头。//www.sina.com ,也可以写为.* 任意都跳转 } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name www.sohu.com; access_log logs/sohu.access.log main; location / { root /web/sohu; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } 例2:静态index.html跳转到动态index.php文件 cd /web/sina/ vi index.php <? print_r ($_GET); ?> Vi nginx.conf server { listen 80; server_name www.sina.com; access_log logs/sina.access.log main; location / { root /web/sina; index index.html index.htm; rewrite ^/index(d+).html /index.php?id=$1 last; # ^/ 以/开头。d+ 多个数字。()第一个变量。 /index.php?id=$1 把第一个变量赋予id变量,传入index.php文件 } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ .php$ { root /web/sina; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 在客户端输入:http://www.sina.com/index2.html 会跳转到index.php,把2当变量传入index.php程序 25.代理负载均衡技术(反向代理) upstream myweb1 { #定义地址池 192.168.190.190 反向代理 upstream myweb1 { server 192.168.190.190:80; server 192.168.190.191:80; } server { listen 80; server_name www.sohu.com; location / { proxy_pass http://myweb1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } } server 192.168.244.10:80; server 192.168.244.11:80; } server { listen 80; server_name www.sohu.com; 192.168.190.191 #使用www.sohu.com访问 location / { proxy_pass http://myweb1; #使用地址池 proxy_set_header Host $host; #利用HOST变量向后端服务器传递需要解析的客户端访问的域名(传递域名) proxy_set_header X-Forwarded-For $remote_addr; #$remote_addr 把客户端真实IP赋予X-Forwarded-For。后端服务器才能获取真实的客户端IP。以便记录日志,要不日志中记录的访问信息都是负载服务器,而不是客户端(传递IP) (编辑:十堰站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |