计算依据参考:https://blog.csdn.net/solmyr_biti/article/details/53955141
pm.max_children = Total RAM dedicated to the web server / Max child process size – in my case it was 85MB
The server has 8GB of RAM, so:
pm.max_children = 6144MB / 85MB = 72
wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz
tar zxvf jpegsrc.v9b.tar.gz
cd jpeg-9b
./configure –prefix=/usr/local/jpeg –enable-shared –enable-static
make && make install
cd /alidata/server/temp/php-5.6.30/ext/gd
make clean
/alidata/server/php56/bin/phpize
./configure –with-php-config=/alidata/server/php56/bin/php-config –with-png-dir –with-freetype-dir=/usr/local/freetype.2.1.10 –with-jpeg-dir=/usr/local/jpeg –with-zlib-dir –with-gd
make && make install
/etc/init.d/php56-fpm restart
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.2.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.0.tar.gz
tar -xf apr-1.6.2.tar.gz
tar -xf apr-util-1.6.0.tar.gz
着手编译
首先编译apr
cd apr-1.6.2
./configure --prefix=/usr/local/apr //指定安装位置
make && make install
编译apr-util
cd apr-util-1.6.0
./configure --with-apr=/usr/local/apr/ --prefix=/usr/local/apr-util //指定apr所在目录及apr-util安装目录
make && make install
在这里会报一个错,如下所示
xml/apr_xml.c:35:19: error: expat.h: No such file or directory //注意这一行,提示没有expat.h这个头文件
xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’
......强行省略.....
xml/apr_xml.c: In function ‘do_parse’:
xml/apr_xml.c:434: error: ‘apr_xml_parser’ has no member named ‘xp’
.....不要看我......
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/apr-util-1.6.0'
make: *** [all-recursive] Error 1
expat是解析XML的程序,是不是想立马执行yum install expat-devel呢?
然而我可以告诉你,然并卵!
不管是base库中的2.0版还是epel库中的2.1版在后面编译httpd的时候都会报错!
所以,我们去expat的官网去下载最新版的expat。
cd ~
wget https://nchc.dl.sourceforge.net/project/expat/expat/2.2.3/expat-2.2.3.tar.bz2
tar -xf expat-2.2.3.tar.bz2
cd expat-2.2.3
./configure --prefix=/usr/local/expat23
make && make install
现在可以重新编译apr-util了
cd ~
cd apr-util-1.6.0
./configure --with-apr=/usr/local/apr/ --with-expat=/usr/local/expat23/ --prefix=/usr/local/apr-util
make clean //因执行过一次编译了,保险起见把那些编译出来的东东删掉,虽然理论上并不影响
make && make install
编译httpd
cd ~
cd httpd-2.4.27
./configure --prefix=/alidata/server/httpd24 --sysconfdir=/alidata/server/httpd24/conf --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
到这一步会报错,提示我们没有装pcre,报错如下:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
执行yum install pcre-devel即可
./configure --prefix=/alidata/server/httpd24 --sysconfdir=/alidata/server/httpd24/conf --with-mpm=prefork --enable-mpms-shared=all --enable-mods-shared=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make && make install
/usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open’ /usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv’ /usr/local/src/php-5.3.10/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close’ collect2: ld returned 1 exit status make: *** [sapi/fpm/php-fpm] 错误
Update: Things are all change in Zend Framework 1.8, so this may require some adaptation in that version.
If you’ve followed the Zend Framework quickstart tutorial like me, you may be wondering how to perform unit testing using it. The tutorial does set up the bootstrap file to allow for unit testing, but does not cover unit testing itself. The aim of this post is to provide a quick guide to unit testing using the quickstart application, which will hopefully come in useful for a few people and myself when I inevitably forget this later on.
Step 0: Before Starting
First, you should download and set up the guestbook application from the Zend Framework website. Make sure you place the Zend library in the library folder and enable the read/write permissions for the sqlite database and the db directory for access by the web server.
You will also want to install pear and, with it, install PHPUnit:
pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
Step 1: Create Test Folders
Create a folder called “tests” in the root folder of the application. Inside that create a folder called “controllers” and “models”. The directory structure should be as follows:
zendquickstart
|-- application
|-- data
|-- library
|-- public
|-- scripts
`--tests
|-- controllers
`-- models
All your controller tests should go in the controllers folder, all your model tests should go in the models folder.
Step 2: Create Test Configuration
Create the file TestConfiguration.php in the tests folder. This file will initially set up the testing configuration, inside place the following code:
<?php// Gets called when this file is included/required
TestConfiguration::setUp();classTestConfiguration{/**
* Sets the environment up for testing
*/staticfunctionsetUp(){// Set the environment constant to testing which will load the testing
// configuration in app.ini by the bootstrap
define('APPLICATION_ENVIRONMENT','testing');// Set the include path for locating the Zend library
set_include_path(realpath(dirname(__FILE__)).'/../library'.PATH_SEPARATOR.get_include_path());// Use Autoload so that we don't have to include/require every class
require_once"Zend/Loader.php";Zend_Loader::registerAutoload();}staticfunctionsetUpDatabase(){require'../application/bootstrap.php';$db=Zend_Registry::get('configuration')->database->params->dbname;// delete any pre-existing databases
if(file_exists($db))unlink($db);// run the database set up script to recreate the database
require'../scripts/load.sqlite.php';}}?>
The setUp() function in this class will get called when the file is included or required. The APPLICATION_ENVIRONMENT constant is set to ‘testing’ so that the testing section of the app.ini file is read in the bootstrap, and the testing database is used. A testing database should be used so that testing does not interfere with the production or development databases, and no important data is lost. The next step is to set the include path, which should contain the location of the Zend Framework library. The final step is to enable the Zend autoloader so that we don’t have to explicitly require/include the Zend libraries.
The setUpDatabase() function resets the database to a known state. When the tests are run we may wish to insert data to the database and this should be removed before every new test. We require the bootstrap file so we can get the database configuration and delete the database file, which is an easy way to reset an SQLite database. A different method will be necessary for other databases like MySQL or PostgreSQL. Finally, the setUpDatabase() function uses a script which comes with the quick start application to (re)create the database.
Step 3: Creating Controller Tests
To test the IndexController, create the file IndexControllerTest.php in the tests/controller directory. The following is a simple example:
<?php// Set up the testing environment
require'TestConfiguration.php';classcontrollers_IndexControllerTestextendsZend_Test_PHPUnit_ControllerTestCase{// Bootstraps the application
public$bootstrap='../application/bootstrap.php';publicfunctiontestHomePageIsASuccessfulRequest(){// Runs the test on /, the homepage
$this->dispatch('/');// Tests there are no exceptions on the home page
$this->assertFalse($this->response->isException());// Tests for redirection to the error handler
$this->assertNotRedirect();}publicfunctiontestHomePageDisplaysCorrectContent(){// Runs the test on /
$this->dispatch('/');// Tests the page title is present
$this->assertQueryContentContains('div#header-logo','ZF Quickstart Application');// Tests the guestbook link is present
$this->assertQueryContentContains('a','Guestbook');}}?>
This is a very basic controller test. First note that you should extend Zend_Test_PHPUnit_ControllerTestCase for controller tests. This class extends PHPUnit_Framework_TestCase itself, but adds some assertions and other things specific to Zend Framework.
The bootstrap instance variable must be set in order to test the controller, and in this case it points to the location of the bootstrap file.
The testHomePageIsASuccessfulRequest() test is used to test that the homepage functions correctly; it should not contain any exceptions or redirect to the error controller. If it does then there is a problem somewhere and the test fails. The testHomePageDisplaysCorrectContent() is used to test that the page title and the link to the guestbook is present.
Step 4: Creating Model Tests
To test the GuestBook model, create the file GuestBookTest.php in tests/models.
<?phprequire'TestConfiguration.php';require'../application/models/GuestBook.php';classmodels_GuestBookTestextendsPHPUnit_Framework_TestCase{publicfunctionsetUp(){// Reset database state
TestConfiguration::setUpDatabase();}publicfunctiontestFetchEntries(){// Instantiate the GuestBook model
$guestBook=newModel_GuestBook();// Get all entries from the database
$entries=$guestBook->fetchEntries();// Test that there are 2 entries in the guestbook
$this->assertSame(2,count($entries));}}?>
Again, this is very basic. The setUp() function gets called by PHPUnit before the test is run, and it will reset the database. The testFetchEntries() function tests the fetchEntries() function in the model. Two rows in the guestbook table should be present, therefore there should be two elements in the array returned by fetchEntries().
Step 5: Edit load.sqlite.php
You may find it annoying to have to wait 5 seconds between model tests when the database is recreated. I worked around this problem by making a small change to the PHP script which loads the database schema:
1
2
3
4
5
6
7
8
9
<?phpif(APPLICATION_ENVIRONMENT!='testing'){echo'Writing Database Guestbook in (control-c to cancel): '.PHP_EOL;for($x=5;$x>0;$x--){echo$x."\r";sleep(1);}}?>
If the application environment is not testing then the timeout should not be displayed. You may prefer to simply remove the timeout altogether. Additionally, you will need to change the lines that locate the SQL files to include dirname(FILE):
To run the tests, navigate to the tests directory in a terminal/CMD, and type phpunit controllers_IndexControllerTest and models_GuestBookTest to test the IndexController and GuestBook model, respectively.
phpunit controllers_IndexControllerTest
PHPUnit 3.3.14 by Sebastian Bergmann.
..
Time: 0 seconds
OK (2 tests, 4 assertions)
phpunit models_GuestBookTest
PHPUnit 3.3.14 by Sebastian Bergmann.
Database Created
Data Loaded.
.
Time: 0 seconds
OK (1 test, 1 assertion)
Conclusion
There you have it. This isn’t necessarily the only way or the best way to perform unit testing, this is merely the way I got it to work with the quickstart application having had no prior experience with PHPUnit. Any suggestions or improvements are welcome.