phptest

php学习, 代码一分钟配置两小时
woc描述

 --------------------------------start--------------------------------------------------------------------------------------------
#开始start.......
#linux命令


#创建文件, aa
touch aa

#解压文件, aa.tar.gz
tar zxvf aa.tar.gz



#移动文件, httpd-2.4.41
sudo mv /home/hkzck/Downloads/httpd-2.4.41 /usr/local/httpd-2.4.41

#更改权限, phpinfo.php
sudo chmod -R  777 phpinfo.php

#关于lnmp
hkzck@hkzck-PC:~$ sudo lnmp
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Usage: lnmp {start|stop|reload|restart|kill|status}
Usage: lnmp {nginx|mysql|mariadb|php-fpm|pureftpd} {start|stop|reload|restart|kill|status}
Usage: lnmp vhost {add|list|del}
Usage: lnmp database {add|list|edit|del}
Usage: lnmp ftp {add|list|edit|del|show}
Usage: lnmp ssl add
Usage: lnmp {dnsssl|dns} {cx|ali|cf|dp|he|gd|aws}
Usage: lnmp onlyssl {cx|ali|cf|dp|he|gd|aws}

 --------------------------------start--------------------------------------------------------------------------------------------







结果:

1.php终于运行出一个程序了...
2.nginx安装好后配置文件,监听端口和程序目录改了一下
3.设置了默认首页
4.跨域概念,称 同协议 + 同域名 +  同端口为同源,一个域
  1. 最后截图,我c
    在这里插入图片描述
code部分:
hello不world,打印数字:
for ($i=1; $i<=5; $i++)
{
   echo "The number is " . $i . "<br>";
}
完整代码:放在root目录下,那如果你是nginx想我一样,自己指定一个目录放就完事了
<?php phpinfo(); //我赌这个函数里面有一万个字...

for ($i=1; $i<=5; $i++) {
    echo "The number is " . $i . "<br>"; }

?> 







  --------------------------------END------------------------------------------------------------------------------------------

在这里插入图片描述

#nginx配置

#运行用户
user  www;

#启动进程,通常设置成和cpu的数量相等
worker_processes auto;
worker_cpu_affinity auto;

#全局错误日志及PID文件
error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

#工作模式及连接数上限
events
    {
        use epoll;                      #epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以大大提高nginx的性能
        worker_connections 51200;       #单个后台worker process进程的最大并发链接数
        multi_accept off;
        accept_mutex off;
    }

#设定http服务器,利用它的反向代理功能提供负载均衡支持
http
    {
        #设定mime类型,类型由mime.type文件定义
        include       mime.types;
        default_type  application/octet-stream;

        server_names_hash_bucket_size 128;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile on;
        sendfile_max_chunk 512k;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        #limit_conn_zone $binary_remote_addr zone=perip:10m;
        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

        server_tokens off;
        access_log off;

server
    {
        #侦听80端口
        listen 9090;
        #listen [::]:80 default_server ipv6only=on;
        #定义使用www.xx.com访问
        server_name www.xx.com;
        index index.html index.htm index.php;
        root  /home/wwwroot/default;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location / {
          root   /home/wwwroot/default/;      #定义服务器的默认网站根目录位置
          index phpinfo.php; #index.php index.html index.htm;   #定义首页索引文件的名称

          #fastcgi_pass  www.xx.com;
         fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name; 
          #include /etc/nginx/fastcgi_params;
        }

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }





include vhost/*.conf;
}



 --------------------------------END-------------------------------------------------------------------------------------------
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值