一) nginx 简介 nginx #软件负载均衡 # 卖给 F5(硬件负载均衡 Load Balancer/LB ) ==> upstream/backend 二)lnmp 环境搭建起来,编译安装。 2.1) 编译安装nginx yum -y install gcc gcc-c++* openssl openssl-devel zlib zlibdevel pcre pcre-devel yum -y groupinstall "Development Tools" yum -y install libxml2 libxml2-dev libxslt-devel yum -y install gd-devel yum -y install perl-devel perl-ExtUtils-Embed yum -y install GeoIP GeoIP-devel GeoIP-data \ ncurses ncurses-devel \ libtool-ltdl-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel \ freetype-devel libXpm-devel gettext-devel useradd -M -s /sbin/nologin nginx ./configure --prefix=/usr/local/nginx --user=nginx \ --group=nginx --with-http_stub_status_module --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_ssl_module make && make install # make -j4 && make install # make -j$(nproc) && make install 80 ln -sf /usr/local/nginx/sbin/nginx /usr/local/sbin/ 81 ls /usr/local/sbin/ 82 echo $PATH nginx -t # 测试配置文件语法是否有错误。 httpd -t # dhcpd -t # named-checkconf #/etc/named.conf listen { 127.0.0.1; 192.168.139.110; }; named-checkzone qm123.com /var/named/qm123.com.zone man 7 signal ## kill -9 -9的含义 killall -s HUP nginx ##重新加载 配置文件。 # nginx.conf user nobody; #运行用户 worker_processes 4; #启动进程,通常设置成和“cpu的数量相等” 上下文切换 context switch # 一般设置为 4 8 ## 优化,调优 tuning tune ## 基于压力测试的数据 # 压力测试 benchmark ## concurrency 并发 如ab 命令 apache benchmark. ab -n 50000 -c 100 http://192.168.139.80/ # 调优示范。 ulimit 命令 ulimit -n #系统打开的文件数 上限。 vi /etc/security/limits.conf # tail -5 /etc/security/limits.conf #number of file 系统能打开的文件数。 * soft nofile 500000 * hard nofile 500000 curl 'https://baike.baidu.com/item/F5/7612514' server { listen 80; server_name www.qingmei.com; charset utf8; #access_log logs/host.access.log main; location / { root /var/www/html; index index.html index.htm; } #添加虚拟目录 location /status{ stub_status on; //启用HTTP_STUB_STATUS状态统计模块 access_log off; //关闭该目录访问日志 } } 三)lnmp环境搭建 yum -y install gcc gcc-c++ cmake make yum -y install libtool zlib zlib-devel pcre pcre-devel \ openssl openssl-devel ncurses ncurses-devel bison mkdir -p /data useradd -M -s /sbin/nologin mysql chown -R mysql:mysql /data ./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 2、编辑脚本控制程序: [root@jianfeng ~]# vim /etc/init.d/mysqld ./mysqladmin -uroot password "123.com" [root@jianfeng bin]# mysql -uroot -p123.com mysql> create database wordpress; mysql> grant all on *.* to "root"@"127.0.0.1" identified by '123.com'; mysql> quit; yum -y install \ libjpeg \ libjpeg-devel \ libpng libpng-devel \ freetype freetype-devel \ libxml2 \ libxml2-devel \ zlib zlib-devel \ curl curl-devel \ openssl openssl-devel ./configure \ --prefix=/usr/local/php \ --with-mysql-sock=/data/mysql.sock \ --with-mysqli \ --with-zlib \ --with-curl \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --with-openssl \ --enable-fpm \ --enable-mbstring \ --enable-xml \ --enable-session \ --enable-ftp \ --enable-pdo \ --enable-tokenizer make -j4 && make install ### 复制配置文件 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp /usr/src/php-7.3.9/php.ini-development /usr/local/php/php.ini cp /usr/src/php-7.3.9/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm [root@jianfeng ~]# chmod +x /etc/init.d/php-fpm [root@jianfeng ~]# chkconfig --add php-fpm echo 'PATH=/usr/local/php/bin:$PATH' >> /etc/profile source /etc/profile location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } Success!!"; else echo "Fail!!"; ?> admin T%3#nKh^Nh4Xpyt9v%