[root@localhost nginx-1.12.2]# ab -c 10 -n 10 http://192.168.4.5/ #压力测试
修改主配置文件
worker_processes 2; cpu 核心数
events{
worker_connections 65535; 每个进程的连接数
}
[root@room9pc01 ~]# ulimit -Hn 访问文件数量的硬件设置 * 绝对不能超过
4096
[root@room9pc01 ~]# ulimit -Sn 访问文件数量的软件数量设置
1024
[root@room9pc01 ~]# ulimit -Sn 2000 临时修改
[root@room9pc01 ~]# ulimit -Sn
2000
[root@room9pc01 ~]# vim /etc/security/limits.conf 修改配置文件永久设置
[root@localhost nginx]# vim /usr/local/nginx/conf/nginx.conf
在http 中
client_header_buffer_size 100k; 用户请求数据头部大小
large_client_header_buffers 4 1000k; 如果之前的大小不够,再开启4个1000K 的空间
本地缓存静态数据优化
about:cache 看缓存
[root@localhost nginx]#vim /usr/local/nginx/conf/nginx.conf
48 location ~* .(jpg|png|gif|bmp)${
49 expires 30d
50 }
[root@proxy nginx]# sbin/nginx -s reload
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory)
[root@proxy nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
将图片移到 /usr/local/nginx/html
192.168.4.5/timg.jpg 浏览器查看
[root@web1 php_scripts]# cp test.php /usr/local/nginx/html/
[root@web1 nginx]# systemctl start mariadb
[root@web1 nginx]# systemctl start php-fpm
cp test.php /usr/local/nginx/html/
[root@web1 nginx]# ss -ntulp | grep mysql
[root@web1 nginx]# ss -ntulp | grep php-fpm
[root@web1 nginx]# ss -ntulp | grep nginx
session 储存在服务器,保存用户名\登陆状态等信息
cookies:由服务器下发给客户端,保存在客户端的一个文件里
[root@web1 php_scripts]# tar -xf php-memcached-demo.tar.gz
[root@web1 php-memcached-demo]# pwd
/lnmp_soft/php_scripts/php-memcached-demo
[root@web1 php_scripts]# cp -r php-memcached-demo/* /usr/local/nginx/html/
使用浏览器打开192.168.2.100/index.php
[root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf
location / {
root html;
index index.php index.html index.htm;
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME
d
o
c
u
m
e
n
t
r
o
o
t
document_root
documentrootfastcgi_script_name;
include fastcgi.conf;
}
————————————————
[root@localhost nginx]# ls /var/lib/php/session/
sess_abd2cku609u0vtk6tj05bfbnh0
建立集群
proxy:
upstream web {
server 192.168.2.100 ;
server 192.168.2.200 ;
}
location / {
root html;
index index.html index.htm;
proxy_pass http://web; 集群名字是web
}
web1:
[root@localhost nginx]# cd /usr/local/nginx/html
[root@localhost html]# vim index.php