We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Is phalcon.so safety on thread (php-zts) ?

my linux box is................ CentOS 5.8 httpd (worker MPM - thread model) php 5.4 (mysqlnd.so + zend thread safety mode) : https://www.webtatic.com/news/2013/07/latest-updates-php-5-5-1-5-4-17/ mysql 5.1

I've just complied & install cphalcon. the result is ............ /etc/php.d/phalcon.ini /usr/lib64/php/modules/phalcon.so

and my phalcon site is displayed the error below Fatal error: Class 'Phalcon\Mvc\Application' not found in /var/www/MYSITE/app/bootstrap.php on line 20 It doesn't work....... also, <?php var_dump( get_loaded_extensions() ); ?> there is no phalcon extension in the result.

phalcon.so is thread safety? where is thread safety version of phalcon.so (for example, phalcon_ts.so) ?

I'm using php 5.4 (in thread safety) of webtatic.com webtatic.com mechanism is.....to change an appropriate php directory automatically (based on apache running mode(worker or prefork)) if apache is running the worker mode, it will find extension conf in /etc/php-zts.d/ directory. else if apache is running the perfork mode, it will find extension in /etc/php.d/ directory.

In my case, it should be installed in the directory(php-zts directory) below. /etc/php-zts/phalcon.ini (extension=/usr/lib64/php-zts/modules/phalcon_ts.so) /usr/lib64/php-zts/modules/phalcon_ts.so

/usr/lib64/php/modules/phalcon.so is thread safety? if so, copy & paste to php-zts directory?

###########################################################

I tried to change apache perfork mode + php non-thread-safe mode It works. phalcon.so is loaded. whereas i tried to change apache worker mode + php thread-safe mode It's NOT works. phalcon.so is NOT loaded.

Is NOT supported apache worker mode + php thread-safe mode ?



98.9k

Phalcon is thread safe: https://github.com/phalcon/cphalcon/search?q=TSRMLS_CC&ref=cmdform

Maybe there are two php-config that produce different flags for thread-safe and non-thread-safe.



4.1k

Okay, I found...../usr/bin/zts-* /usr/bin/zts-php /usr/bin/zts-phpize /usr/bin/zts-php-config

I modified "install" script of phalcon source. (absolute path of phpize and php-config) Line 69 of /usr/local/src/cphalcon/build/install

FROM

perform the complication

phpize && aclocal && $LIBTOOLIZE_BIN --force && autoheader && autoconf && ./configure --enable-phalcon && make && make install && echo -e "\nThanks for compiling Phalcon!\nBuild succeed: Please restart your web server to complete the installation"

TO /usr/bin/zts-phpize && aclocal && $LIBTOOLIZE_BIN --force && autoheader && autoconf && ./configure --enable-phalcon --with-php-config=/usr/bin/zts-php-config && make && make install && echo -e "\nThanks for compiling Phalcon!\nBuild succeed: Please restart your web server to complete the installation"

and save & run "install" script.

The Result /usr/lib64/php-zts/modues/phalcon.so

and then, create file below /etc/php-zts.d/phalcon.ini with extension=phalcon.so

Restart httpd.(service httpd restart)

It works.( httpd worker mode + php 5.4 zend thread safe mode )

References

https://blog.famillecollet.com/post/2011/10/15/PHP-and-PECL-extensions-for-ZTS https://forums.famillecollet.com/viewtopic.php?id=1724 https://stackoverflow.com/questions/6471434/how-to-compile-php-extension-for-php-5-3-6-with-debug-ts

What is the reason to use ZTS on Linux? ZTS binaries are a bit slower than non-ZTS ones.



4.1k

I'm going to use pthread extension + phalcon extension + apache worker mode (the main reason is because apache perfork mode is memory killer. memory is increased continually and not decreased) by the way pthread requires php-zts.

Is it really slow than general php mode ? what is non-ZTS solution ? apache worker mode + php fast cgi mode ?

Slower, not slow :-) In my tests php-zts is up to 5% slower than non-ZTS binary (thread safety comes at a price), however, your mileage may vary. But if you have to use pthreads, then ZTS is your only option.