rgar12 发表于 2015-5-25 09:47:49

lamp之调试lamp和ab压力测试

LAMP:
    php和mysql建立关联:
      php-mysql

      #yum install php-mysql yum安装的时候才用,编译安装不需要

    php连接mysql测试脚本:
      #vim index.php
      <?php
      $conn = mysql_connect("HOST","USERNAME","PASSWORD") or die("connect err: ".mysql_error());
      echo "MySQL conn OK!";
      ?>

    httpd+php
      CGI
      Modules
      FastCGI/fpm

测试LAMP:
    1.测试php
      #cd /usr/local/httpd/htdocs
      #vim index.html
            <?php
            phpinfo()
            ?>      
      #mv index.html index.php

      编辑完成后打开网页,若能看到php相关信息则说明成功。

    2.测试php和mysql
      #vim index.php
      <?php
      $conn = mysql_connect("HOST","USERNAME","PASSWORD") or die("connect err: ".mysql_error());
      echo "MySQL conn OK!";
      ?>

      编辑完成后若显示conn ok则表示数据路连接正常。

    3.启用虚拟主机
      #vim /etc/httpd/httpd.conf
            #DocumentRoot /usr/local/httpd/htdocs 注释中心主机配置
            Include /etc/httpd/extra/httpd-vhost.conf 取消注释,启动虚拟主机的配置文件。
            LoadModule log_config_modules/mod_log_config.so 启动日志配置模块。

      #vim /etc/httpd/extra/httpd-vhost.conf
            <VirtualHost 192.168.123.10:80>
                ServerName www.test.com
                DocumentRoot "/www/test.com"
                ErrorLog "/var/log/httpd/test.com_error_log"
                CustomLog "/var/log/httpd/test.com_access_log"
                combined
                <Directory "/www/test.com">
                  Options none
                  AllowOverride none
                  Require all granted
                </Directory>

            </VirualHost>

            <VirtualHost 192.168.123.10:80>
                ServerName www.apk.org
                DocumentRoot "/www/apk.org"
                ErrorLog "/var/log/httpd/apk.org_error_log"
                CustomLog "/var/log/httpd/apk.org_access_log" common
                <Directory "/www/apk.org">
                  Options none
                  AllowOverride none
                  Require all granted
                </Directory>
            </VirualHost>

      #mkdir /www/{test.com,apk.org}
      #mkdir /var/log/httpd/{test.com,apk.org}
      #chmod 755 -R /www


    3.让httpd支持https,可以对单独的虚拟主机进行设置。

      注意:一个ip地址上只能建立1个支持ssl的主机。

      #vim /etc/httpd/httpd.conf
            LoadModule ssl_module modules/mod_ssl.so
            Include /etc/httpd/extra/httpd-ssl.conf

      #vim /etc/httpd/extra/httpd-ssl.conf
            <VirtualHost * :443>
                ServerName www.apk.org
                DocumentRoot "/www/apk.org"
                ErrorLog "/var/log/httpd/apk.org_error_log"
                TransferLog "/var/log/httpd/apk.org_access_log" common
                <Directory "/www/apk.org">
                  Options none
                  AllowOverride none
                  Require all granted
                </Directory>
            </VirualHost>


      证书服务器上:
            1.生成私钥:
                #cd /etc/pki/CA
                #(umask 077;openssl genrsa -out private/cakey.pem 2048)

            2.编辑openssl配置文件:
                #vim ../tls/openssl.cnf
                  dir=/etc/pki/CA 修改CA默认目录。

                  [ req_distinguished_name ]

                  修改国家、份等等信息,后续再次申请就无需输入。

                #mkdir certs crl newcerts 根据配置文件的内容创建相关的文件夹和文件
                #touch index.txt
                #echo 00 > serial

            3.生成自签证书:
                #openssl req -new -x509 -key private/cakey.pem -out    cacert.pem -days 3650
                  Common Name: ca.test.com 这里填CA的主机名。


            6.签署证书:
                #openssl ca -in /tmp/httpd.csr -out /tmp/httpd.crt -dyas 3650

      httpd服务器上:
            4.生成证书请求:
                #cd /etc/httpd/
                #mkdir ssl
                #cd ssl
                #(umask 077;openssl genrsa 2048 > httpd.key ) 生成私钥。
                #openssl req -new -key httpd.key -out httpd.csr 生成证书签署请求。
                  Common Name: 虚拟主机的名称。

            5.将生成的证书请求文件复制到证书服务器:
                #scp httpd.scr root@192.168.100.4:/tmp

            7.将颁发的证书复制到本机:
                #scp 192.168.100.4:/tmp/httpd.crt ./
                #ll
                  httpd.crt
                  httpd.csr
                  httpd.key


    4.若php以fpm模式安装,则还需要对httpd进行如下配置:
      启用模块支持:
            #vim /etc/httpd/httpd.conf
                LoadModule proxy_module modules/mod_proxy.so
                LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

      配置虚拟主机支持fpm:
            #vim /etc/httpd/extra/httpd-vhost.conf
                在每个虚拟主机内添加如下内容
                ProxyRequests Off
                  关闭httpd的正向代理功能。

                ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/DIR/DOCUMENT_ROOT/$1
                  类似于ProxyPass URI,将请求的地址转换到另外一台主机上的地址。此行为被称为反向代理。
                  此参数支持正则表达式,把以.php结尾的文件请求发送到php-fpm进程,php-fpm至少需要知道运行的目录和URI,所以这里直接在fcgi://127.0.0.1:9000后指明了这两个参数,其它的参数的传递已经被mod_proxy_fcgi.so进行了封装,不需要手动指定。

            例如:
                <VirtualHost *:80>
                  DocumentRoot "/www/test.com"
                  ServerName test.com
                  ServerAlias www.test.com

                  ProxyRequests Off
                  ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/www/test.com/$1

                  <Directory "/www/test.com">
                        Options none
                        AllowOverride none
                        Require all granted
                  </Directory>
                </VirtualHost>

压力测试:
    ab(apache benchmark)
      工具位置:
            httpd安装目录下的bin文件夹下。
            usr/local/httpd/bin/ab

            #ab HOSTNAME|IP:PORT/FILE
               
                  -c NUM 指定并发数,单次发起的请求个数。
                  -n NUM 请求的总个数。
                  -r 忽略错误信息


      例如:
            #ab -c 10 -n 100 http://www.test.com/index.php


      注意:
            测试所用的客户端会有系统限制,默认linux允许单个进程同时访问1000个文件。使用以下命令调整
            #ulimit -n NUM

    http_load
    webbench
    siege

LAMP优化:
    通过vmstat命令观察系统状况,主要注意bi bo in cs

    #vmstat 1

SGPMENU 发表于 2023-3-21 19:21:06

Beta_Fish 发表于 2023-3-25 16:45:30

this is a good post but you visit Also, betafishinfo

Beta_Fish 发表于 2023-3-26 23:53:17

thanks for visiting Song FA Bak Kut Teh Singapore Menu

offwala 发表于 2023-4-18 19:14:12

<a href="https://www.irelandlanyards.com/ is a member of the European Union and has a strong economy that is driven by industries such as technology, pharmaceuticals, and financial services.

offwala 发表于 2023-4-18 19:40:56

https://elitechauffeurs.ie/are high-end transportation services that provide professional drivers and luxury vehicles to cater to the needs of discerning clients.

offwala 发表于 2023-4-23 18:04:25

ITAR compliancehttps://clearedsystems.com/how-to-become-itar-compliant/ is important for companies and organizations that deal with defense-related items or information because failing to comply with ITAR regulations can result in significant legal and financial consequences, including fines, imprisonment, and loss of export privileges.


offwala 发表于 2023-4-24 22:14:12

สล็อตเว็บตรงที่แตกง่ายและไม่ล็อคยูส์ หมายความว่าเป็นเกมสล็อตที่มีสัดส่วนการจ่ายเงินสูง และไม่มีการล็อคยูส์หรือขั้นตอนการยืนยันตัวตนที่ยุ่งยาก ซึ่งจะช่วยเพิ่มโอกาสในการชนะเงินรางวัลของผู้เล่นในเกมสล็อตเว็บตรง

https://ufabet.cloud/direct-web-slots-no-user-locks/

Beta_Fish 发表于 2023-5-2 22:42:46

Insulation services are crucial for maintaining comfortable and energy-efficient indoor environments. Insulation helps to regulate the temperature and reduce heat loss, keeping the indoor space warm in winter and cool in summer.

offpagevce76wyu 发表于 2023-6-6 14:45:29

www.allsgpromo.com_.png]Subway Singapore Price is a popular fast-food chain that has gained immense popularity among locals and tourists alike. With its origins in the United States, Subway has expanded its reach globally and has successfully established a strong presence in the vibrant city-state of Singapore.

offpagevce76wyu 发表于 2023-6-6 20:19:04

At Direct Line Timber, customers can expect the best prices for all their timber needs. With a commitment to providing high-quality products at affordable rates, Direct Line Timber has established itself as a trusted source for timber supplies. it you want to get more information than this website.

HarryMarry 发表于 2024-6-1 15:20:05

The Jollibee Chicken Sandwich is a delightful addition to the menu, featuring a crispy fried chicken fillet tucked between soft buns, topped with mayonnaise, lettuce, and a slice of cheese. https://www.jollibeemenuph.com/

easzag3523 发表于 前天 16:38

If you’re managing your own website and looking to enhance the experience, make sure to check out Netmirror, which offers a seamless platform for streaming and downloading content. It can help you keep your entertainment options optimized while working on your server."**

easzag3523 发表于 前天 16:38

If you’re managing your own website and looking to enhance the experience, make sure to check out Netmirror, which offers a seamless platform for streaminghttps://netmirror-apk.com/ and downloading content. It can help you keep your entertainment options optimized while working on your server."**

页: [1]
查看完整版本: lamp之调试lamp和ab压力测试