Eugeny / ajenti-v

Virtual Hosting addon for Ajenti
ajenti.org/#product-ajenti-v
MIT License
225 stars 80 forks source link

PHP7.0 & PHP5.6 FPM on Ubuntu 14+ #213

Closed alessiodionisi closed 8 years ago

alessiodionisi commented 8 years ago

Install add-apt-repository requisites

apt-get install software-properties-common

Add ppa:ondrej/php repository

add-apt-repository ppa:ondrej/php
apt-get update

Purge old php5 and ajenti-v-php-fpm

apt-get purge ajenti-v-php-fpm
apt-get purge php5-*
apt-get autoremove

Install php5.6 & php7.0

apt-get install php5.6-fpm php5.6-mysql php7.0-fpm php7.0-mysql

Apply my new patched files and enjoy php5.6 & php7.0!

Available PHP7.0 packages:

p   libapache2-mod-php7.0                                            - server-side, HTML-embedded scripting language (Apache 2 module)            
p   libapache2-mod-php7.0:i386                                       - server-side, HTML-embedded scripting language (Apache 2 module)            
p   libphp7.0-embed                                                  - HTML-embedded scripting language (Embedded SAPI library)                   
p   libphp7.0-embed:i386                                             - HTML-embedded scripting language (Embedded SAPI library)                   
p   php7.0                                                           - server-side, HTML-embedded scripting language (metapackage)                
p   php7.0-bz2                                                       - bzip2 module for PHP                                                       
p   php7.0-bz2:i386                                                  - bzip2 module for PHP                                                       
p   php7.0-cgi                                                       - server-side, HTML-embedded scripting language (CGI binary)                 
p   php7.0-cgi:i386                                                  - server-side, HTML-embedded scripting language (CGI binary)                 
i A php7.0-cli                                                       - command-line interpreter for the PHP scripting language                    
p   php7.0-cli:i386                                                  - command-line interpreter for the PHP scripting language                    
i A php7.0-common                                                    - Common files for packages built from the PHP source                        
p   php7.0-curl                                                      - CURL module for PHP                                                        
p   php7.0-curl:i386                                                 - CURL module for PHP                                                        
p   php7.0-dbg                                                       - Debug symbols for PHP7.0                                                   
p   php7.0-dbg:i386                                                  - Debug symbols for PHP7.0                                                   
p   php7.0-dev                                                       - Files for PHP7.0 module development                                        
p   php7.0-dev:i386                                                  - Files for PHP7.0 module development                                        
p   php7.0-enchant                                                   - Enchant module for PHP                                                     
p   php7.0-enchant:i386                                              - Enchant module for PHP                                                     
i   php7.0-fpm                                                       - server-side, HTML-embedded scripting language (FPM-CGI binary)             
p   php7.0-fpm:i386                                                  - server-side, HTML-embedded scripting language (FPM-CGI binary)             
p   php7.0-gd                                                        - GD module for PHP                                                          
p   php7.0-gd:i386                                                   - GD module for PHP                                                          
p   php7.0-gmp                                                       - GMP module for PHP                                                         
p   php7.0-gmp:i386                                                  - GMP module for PHP                                                         
p   php7.0-imap                                                      - IMAP module for PHP                                                        
p   php7.0-imap:i386                                                 - IMAP module for PHP                                                        
p   php7.0-interbase                                                 - Interbase module for PHP                                                   
p   php7.0-interbase:i386                                            - Interbase module for PHP                                                   
p   php7.0-intl                                                      - Internationalisation module for PHP                                        
p   php7.0-intl:i386                                                 - Internationalisation module for PHP                                        
i A php7.0-json                                                      - JSON module for PHP                                                        
p   php7.0-json:i386                                                 - JSON module for PHP                                                        
p   php7.0-ldap                                                      - LDAP module for PHP                                                        
p   php7.0-ldap:i386                                                 - LDAP module for PHP                                                        
p   php7.0-mcrypt                                                    - libmcrypt module for PHP                                                   
p   php7.0-mcrypt:i386                                               - libmcrypt module for PHP                                                   
p   php7.0-modules-source                                            - PHP 7.0 modules source package                                             
i   php7.0-mysql                                                     - MySQL module for PHP                                                       
p   php7.0-mysql:i386                                                - MySQL module for PHP                                                       
p   php7.0-odbc                                                      - ODBC module for PHP                                                        
p   php7.0-odbc:i386                                                 - ODBC module for PHP                                                        
i A php7.0-opcache                                                   - Zend OpCache module for PHP                                                
p   php7.0-opcache:i386                                              - Zend OpCache module for PHP                                                
p   php7.0-pgsql                                                     - PostgreSQL module for PHP                                                  
p   php7.0-pgsql:i386                                                - PostgreSQL module for PHP                                                  
p   php7.0-phpdbg                                                    - server-side, HTML-embedded scripting language (PHPDBG binary)              
p   php7.0-phpdbg:i386                                               - server-side, HTML-embedded scripting language (PHPDBG binary)              
p   php7.0-pspell                                                    - pspell module for PHP                                                      
p   php7.0-pspell:i386                                               - pspell module for PHP                                                      
i A php7.0-readline                                                  - readline module for PHP                                                    
p   php7.0-readline:i386                                             - readline module for PHP                                                    
p   php7.0-recode                                                    - recode module for PHP                                                      
p   php7.0-recode:i386                                               - recode module for PHP                                                      
p   php7.0-snmp                                                      - SNMP module for PHP                                                        
p   php7.0-snmp:i386                                                 - SNMP module for PHP                                                        
p   php7.0-sqlite3                                                   - SQLite3 module for PHP                                                     
p   php7.0-sqlite3:i386                                              - SQLite3 module for PHP                                                     
p   php7.0-sybase                                                    - Sybase module for PHP                                                      
p   php7.0-sybase:i386                                               - Sybase module for PHP                                                      
p   php7.0-tidy                                                      - tidy module for PHP                                                        
p   php7.0-tidy:i386                                                 - tidy module for PHP                                                        
p   php7.0-xmlrpc                                                    - XMLRPC-EPI module for PHP                                                  
p   php7.0-xmlrpc:i386                                               - XMLRPC-EPI module for PHP                                                  
p   php7.0-xsl                                                       - XSL module for PHP                                                         
p   php7.0-xsl:i386                                                  - XSL module for PHP       

Available PHP5.6 packages:

p   libapache2-mod-php5.6                                            - server-side, HTML-embedded scripting language (Apache 2 module)            
p   libapache2-mod-php5.6:i386                                       - server-side, HTML-embedded scripting language (Apache 2 module)            
p   libphp5.6-embed                                                  - HTML-embedded scripting language (Embedded SAPI library)                   
p   libphp5.6-embed:i386                                             - HTML-embedded scripting language (Embedded SAPI library)                   
p   php5.6                                                           - server-side, HTML-embedded scripting language (metapackage)                
p   php5.6-bz2                                                       - bzip2 module for PHP                                                       
p   php5.6-bz2:i386                                                  - bzip2 module for PHP                                                       
p   php5.6-cgi                                                       - server-side, HTML-embedded scripting language (CGI binary)                 
p   php5.6-cgi:i386                                                  - server-side, HTML-embedded scripting language (CGI binary)                 
i A php5.6-cli                                                       - command-line interpreter for the PHP scripting language                    
p   php5.6-cli:i386                                                  - command-line interpreter for the PHP scripting language                    
i A php5.6-common                                                    - Common files for packages built from the PHP source                        
p   php5.6-curl                                                      - CURL module for PHP                                                        
p   php5.6-curl:i386                                                 - CURL module for PHP                                                        
p   php5.6-dbg                                                       - Debug symbols for PHP5.6                                                   
p   php5.6-dbg:i386                                                  - Debug symbols for PHP5.6                                                   
p   php5.6-dev                                                       - Files for PHP5.6 module development                                        
p   php5.6-dev:i386                                                  - Files for PHP5.6 module development                                        
p   php5.6-enchant                                                   - Enchant module for PHP                                                     
p   php5.6-enchant:i386                                              - Enchant module for PHP                                                     
i   php5.6-fpm                                                       - server-side, HTML-embedded scripting language (FPM-CGI binary)             
p   php5.6-fpm:i386                                                  - server-side, HTML-embedded scripting language (FPM-CGI binary)             
p   php5.6-gd                                                        - GD module for PHP                                                          
p   php5.6-gd:i386                                                   - GD module for PHP                                                          
p   php5.6-gmp                                                       - GMP module for PHP                                                         
p   php5.6-gmp:i386                                                  - GMP module for PHP                                                         
p   php5.6-imap                                                      - IMAP module for PHP                                                        
p   php5.6-imap:i386                                                 - IMAP module for PHP                                                        
p   php5.6-interbase                                                 - Interbase module for PHP                                                   
p   php5.6-interbase:i386                                            - Interbase module for PHP                                                   
p   php5.6-intl                                                      - Internationalisation module for PHP                                        
p   php5.6-intl:i386                                                 - Internationalisation module for PHP                                        
i A php5.6-json                                                      - JSON module for PHP 5.6                                                    
p   php5.6-json:i386                                                 - JSON module for PHP 5.6                                                    
p   php5.6-ldap                                                      - LDAP module for PHP                                                        
p   php5.6-ldap:i386                                                 - LDAP module for PHP                                                        
p   php5.6-mcrypt                                                    - libmcrypt module for PHP                                                   
p   php5.6-mcrypt:i386                                               - libmcrypt module for PHP                                                   
p   php5.6-modules-source                                            - PHP 5.6 modules source package                                             
i   php5.6-mysql                                                     - MySQL module for PHP                                                       
p   php5.6-mysql:i386                                                - MySQL module for PHP                                                       
p   php5.6-odbc                                                      - ODBC module for PHP                                                        
p   php5.6-odbc:i386                                                 - ODBC module for PHP                                                        
i A php5.6-opcache                                                   - Zend OpCache module for PHP                                                
p   php5.6-opcache:i386                                              - Zend OpCache module for PHP                                                
p   php5.6-pgsql                                                     - PostgreSQL module for PHP                                                  
p   php5.6-pgsql:i386                                                - PostgreSQL module for PHP                                                  
p   php5.6-phpdbg                                                    - server-side, HTML-embedded scripting language (PHPDBG binary)              
p   php5.6-phpdbg:i386                                               - server-side, HTML-embedded scripting language (PHPDBG binary)              
p   php5.6-pspell                                                    - pspell module for PHP                                                      
p   php5.6-pspell:i386                                               - pspell module for PHP                                                      
i A php5.6-readline                                                  - readline module for PHP                                                    
p   php5.6-readline:i386                                             - readline module for PHP                                                    
p   php5.6-recode                                                    - recode module for PHP                                                      
p   php5.6-recode:i386                                               - recode module for PHP                                                      
p   php5.6-snmp                                                      - SNMP module for PHP                                                        
p   php5.6-snmp:i386                                                 - SNMP module for PHP                                                        
p   php5.6-sqlite3                                                   - SQLite3 module for PHP                                                     
p   php5.6-sqlite3:i386                                              - SQLite3 module for PHP                                                     
p   php5.6-sybase                                                    - Sybase module for PHP                                                      
p   php5.6-sybase:i386                                               - Sybase module for PHP                                                      
p   php5.6-tidy                                                      - tidy module for PHP                                                        
p   php5.6-tidy:i386                                                 - tidy module for PHP                                                        
p   php5.6-xmlrpc                                                    - XMLRPC-EPI module for PHP                                                  
p   php5.6-xmlrpc:i386                                               - XMLRPC-EPI module for PHP                                                  
p   php5.6-xsl                                                       - XSL module for PHP                                                         
p   php5.6-xsl:i386                                                  - XSL module for PHP 
Ardakilic commented 8 years ago

Great job @alessiodionisi , thanks!

I'm not sure, but shouldn't the package name in .desc file be php7.0-fpm instead of php-fpm7.0 in this line ?

alessiodionisi commented 8 years ago

Mmm yes!

gragio commented 8 years ago

wonderful!!

seanmcn commented 8 years ago

:+1:

JapSeyz commented 8 years ago

I am all new to Ajenti, but is there a way to import this plugin right away? Taken that it is a plugin, and not changes to the actual code.

alessiodionisi commented 8 years ago

@JapSeyz your system is Ubuntu?

JapSeyz commented 8 years ago

@alessiodionisi Yes

hajekj commented 8 years ago

@alessiodionisi: Could you please provide some guidance on how to get this running on Ubuntu? Thanks.

h-collector commented 8 years ago

If you really need this patch, then for the time being after upgrading php, you can run

cd /var/lib/ajenti/plugins/
curl https://patch-diff.githubusercontent.com/raw/Eugeny/ajenti-v/pull/213.patch | sudo git apply

It can be reverted later by appending --reverse

Next comes restarting ajenti and in websites interface you should have available PHP7.0 FastCGI as new content provider, restart nginx and it should just work (or so from my memory).

PS. ppa:ondrej/php-7.0 is now deprecated in favour of co-installable PHP 5.6 + 7.0 version ppa:ondrej/php

alessiodionisi commented 8 years ago

Install add-apt-repository requisites

apt-get install software-properties-common

Add ppa:ondrej/php repository

add-apt-repository ppa:ondrej/php
apt-get update

Purge old php5 and ajenti-v-php-fpm

apt-get purge ajenti-v-php-fpm
apt-get purge php5-*
apt-get autoremove

Install php5.6 & php7.0

apt-get install php5.6-fpm php5.6-mysql php7.0-fpm php7.0-mysql

Apply my new patched files and enjoy php5.6 & php7.0!

Xefir commented 8 years ago

Like I said here for another "on-the-edge" request : https://github.com/Eugeny/ajenti-v/issues/188

It's never a good idea to push the early "non-stable" version to a stable product. Your work based on a non official repository you have to add by using the add-apt-repository.

Why did you not just wait until Ubuntu / Debian and other distributions push it on a stable state ?

Because the config path could be change in the stable repository to have a unique php-fpm folder and not the crappy php7.0-fpm we have here.

And moreover if the new stuff break the existing, it's not worth it.

So yeah, your stuff breaks ajenti-v and I push a fix here : https://github.com/Eugeny/ajenti-v/pull/219

No need to rollback, the bad is already in place.

Ardakilic commented 8 years ago

@Xefir

Debian already pushed the PHP7 and it's usable, is it not stable?

https://packages.debian.org/search?keywords=php7.0

alessiodionisi commented 8 years ago

@Xefir Sorry for indentation error caused by GitHub editor. My work add two new plugins and does not break anything. You can use original ajenti-v-php-fpm or one of my plugins with the unofficial (but complete) ondrej/php repository.

Xefir commented 8 years ago

Sorry for my angryness and frustration, it doesn't really help me to go further.

I look on your code and yeah, in theory, it breaks nothing.

And thanks for the debian hint, the last time I check, it was only on the unstable branch (witch could have some huge changes before merge) and not on the testing branch (witch is the branch that will became stable when it was time, so pretty "stable" I guess).

I don't have the time to test php7 yet, I will check later :)

Ardakilic commented 8 years ago

@alessiodionisi

When I want to upgrade from PHP5 to PHP7, should these steps be sufficient ? Are there going to be any losses ?

alessiodionisi commented 8 years ago

@Ardakilic These steps are fine! New plugins does not understand old configurations, copy them somewhere :)

Flandoll commented 8 years ago

@alessiodionisi For these two plugins can not merged with original Plugins inside?

alessiodionisi commented 8 years ago

@Flandoll download a zip of this repository and extract vh-php5.6-fpm and/or vh-php7.0-fpm on /var/lib/ajenti/plugins/

Flandoll commented 8 years ago

@alessiodionisi I am referring to modify the original plugin code rather than by adding Plugins

Ardakilic commented 8 years ago

OK, I've tried but it doesn't create pools, so websites aren't accessible. Any ideas ?

Also, when you create the PHP7.0-FastCGI, matching pattern is just /, nothing is filled.

This is the nginx log:

2016/01/27 11:20:06 [crit] 24661#24661: *928 connect() to unix:/var/run/ajenti-v-php-fcgi-sitecom-php-fcgi-0.sock failed (2: No such file or directory) while connecting to upstream, client: 1.2.3.4, server: site.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/ajenti-v-php-fcgi-sitecom-php-fcgi-0.sock:", host: "www.site.com", referrer: "http://www.site.com/"
alessiodionisi commented 8 years ago

Please check the logs

Working examples: http://php7.alessiodionisi.com/ http://php5.alessiodionisi.com/

Ardakilic commented 8 years ago

Please see my updated edits.

alessiodionisi commented 8 years ago

You have /var/lib/ajenti/plugins/vh/layout/main-backend-params-php5.6-fcgi.xml and /var/lib/ajenti/plugins/vh/layout/main-backend-params-php7.0-fcgi.xml ?

Ardakilic commented 8 years ago

Yup, I have both:

āžœ  layout  pwd
/var/lib/ajenti/plugins/vh/layout
āžœ  layout  ll
total 68K
-rw-rw-r-- 1 1000 1000 1.9K Jan 27 05:41 ext-processes.xml
-rw-rw-r-- 1 1000 1000  192 Jan 27 05:41 main-backend-params-fcgi.xml
-rw-rw-r-- 1 1000 1000  479 Jan 27 05:41 main-backend-params-nodejs.xml
-rw-rw-r-- 1 1000 1000 1.4K Jan 27 05:41 main-backend-params-php-fcgi.xml
-rw-rw-r-- 1 1000 1000 1.4K Jan 27 05:41 main-backend-params-php5.6-fcgi.xml
-rw-rw-r-- 1 1000 1000 1.4K Jan 27 05:41 main-backend-params-php7.0-fcgi.xml
-rw-rw-r-- 1 1000 1000  184 Jan 27 05:41 main-backend-params-proxy.xml
-rw-rw-r-- 1 1000 1000 1.1K Jan 27 05:41 main-backend-params-python-wsgi.xml
-rw-rw-r-- 1 1000 1000  845 Jan 27 05:41 main-backend-params-ruby-puma.xml
-rw-rw-r-- 1 1000 1000  208 Jan 27 05:41 main-backend-params-ruby-unicorn.xml
-rw-rw-r-- 1 1000 1000  211 Jan 27 05:41 main-backend-params-static.xml
-rw-rw-r-- 1 1000 1000 1.4K Jan 27 05:41 main-website-location.xml
-rw-rw-r-- 1 1000 1000 8.3K Jan 27 05:41 main-website.xml
-rw-rw-r-- 1 1000 1000 2.9K Jan 27 05:41 main.xml
-rw-rw-r-- 1 1000 1000  471 Jan 27 05:41 not-configured.xml
āžœ  layout
alessiodionisi commented 8 years ago

Seems he is using the old socket from php5-fpm connect() to unix:/var/run/ajenti-v-php-fcgi-sitecom-php-fcgi-0.sock

Please post your /etc/ajenti/vh.json, only the "locations" array

Ardakilic commented 8 years ago

Here's the locations key of the json:

"locations": [
    {
        "custom_conf_override": false, 
        "path_append_pattern": false, 
        "pattern": "\\.php$", 
        "custom_conf": "", 
        "path": "", 
        "match": "regex", 
        "backend": {
            "params": {
                "pm_min": 1, 
                "pm_max": 2, 
                "php_admin_values": "", 
                "php_flags": "", 
                "pm": "dynamic"
            }, 
            "type": "php7.0-fcgi"
        }
    }
], 
Ardakilic commented 8 years ago

I think I got it. You're right:

Auto-generated nginx config refers the sock to

ajenti-v-php-fcgi-site-php-fcgi-0.sock

But it should be

ajenti-v-php7.0-fcgi-site-php7.0-fcgi-0.sock

How do I fix this ?

alessiodionisi commented 8 years ago

You have the updated ajenti-v-nginx?

https://github.com/Eugeny/ajenti-v/blob/master/vh-nginx/nginx.py https://github.com/Eugeny/ajenti-v/blob/master/vh-nginx/nginx_templates.py

Ardakilic commented 8 years ago

Yes, I have both.

Ardakilic commented 8 years ago

Weird, I have manually restarted all of the nginx services (from services tab) from the daemon and sites started popping up. Some issues remain but I can handle them , thanks @alessiodionisi for the interest and help! :bow:

alessiodionisi commented 8 years ago

@Ardakilic good!

XVII commented 8 years ago

I'm looking to update my websites to php7.0. What was the final upgrade process?

@Eugeny , can a formalized process be published on http://support.ajenti.org/list/27624-kb/?category=9332?

alessiodionisi commented 8 years ago

@ShadowXVII How to:

Please give feedback :)

alessiodionisi commented 8 years ago

ajenti-v-php5.6-fpm_1.0.0.deb.zip ajenti-v-php7.0-fpm_1.0.0.deb.zip

XVII commented 8 years ago

Awesome, working. I used the plugins through apt-get and it worked fine. Had to reboot ajenti to get it to pick up the new plugins. Re-created the PHP 7 content handler and copied the config down.

Thanks!

shadowlik commented 8 years ago

I installed and now i get "Fatal-error-Call-to-undefined-function-simplexml_load_file()" i'm new at all this, i tried to find the solution but nothing, can anyone help me?

Ardakilic commented 8 years ago

@shadowlik I had the exact same issue on a non-ajenti server. The fix was simply installing php7.0-xml . As far as I can tell, between versions, it got separated as a different package.

bbbenji commented 8 years ago

The ondrej repo no longer works. Is there an alternative place I can get php5.6-fpm and php7.0-fpm?

Ardakilic commented 8 years ago

@bbbenji Repository link changed months ago.

Try this (holds both PHP5.6 and PHP7):

https://launchpad.net/~ondrej/+archive/ubuntu/php

And update, upgrade, dist-upgrade in order for packages to upgrade.

bbbenji commented 8 years ago

After upgrading to the 5.6 and 7.0 plugins I am getting Access Denied on all files other than .php including directories without a trailing /. See: https://github.com/Eugeny/ajenti-v/issues/231

Ardakilic commented 8 years ago

@bbbenji

Make sure URL pattern is \.php$, and type is Regex in the content section.

New PHP7 module doesn't do it automatically for me, so I need to set it each time I create/edit FPM.

bbbenji commented 8 years ago

@Ardakilic Oh man, I have been fighting with this for a week now. This solved my issue. Thank you.

Ardakilic commented 8 years ago

@bbbenji You're welcome, glad it solved your issue šŸŽ‰

flemming-petersen commented 8 years ago

I have tried to install ajenti v after i did the workaorund that was discribed in the top but when I start the installation this will be the result. The following packages have unmet dependencies: ajenti-v-php-fpm : Depends: php5-fpm but it is not installable E: Unable to correct problems, you have held broken packages. Can anybody help me?

Ardakilic commented 8 years ago

@flemssound which PHP version do you have?

try typing:

apt-cache search ajenti-v-

and install php ajenti package for the version to your use accordingly.

oguzhanaslan commented 7 years ago

I've done the operations, error after.

global name 'TEMPLATE_LOCATION_CONTENT_PHP7_0_FCGI' is not defined Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/ajenti/plugins/main/main.py", line 158, in handle_message self.ui.dispatch_event(update['uid'], update['event'], update['params']) File "/usr/lib/pymodules/python2.7/ajenti/ui/__init__.py", line 72, in dispatch_event self.root.dispatch_event(uid, event, params) File "/usr/lib/pymodules/python2.7/ajenti/ui/element.py", line 382, in dispatch_event if child.dispatch_event(uid, event, params): File "/usr/lib/pymodules/python2.7/ajenti/ui/element.py", line 382, in dispatch_event if child.dispatch_event(uid, event, params): File "/usr/lib/pymodules/python2.7/ajenti/ui/element.py", line 388, in dispatch_event getattr(self, k)(**(params or {})) File "/var/lib/ajenti/plugins/vh/main.py", line 259, in save self.manager.update_configuration() File "/var/lib/ajenti/plugins/vh/api.py", line 347, in update_configuration self.webserver.create_configuration(self.config) File "/var/lib/ajenti/plugins/vh-nginx/nginx.py", line 160, in create_configuration .write(self.__generate_website_config(website)) File "/var/lib/ajenti/plugins/vh-nginx/nginx.py", line 140, in __generate_website_config ) if not website.maintenance_mode else '', File "/var/lib/ajenti/plugins/vh-nginx/nginx.py", line 139, in <genexpr> '\n'.join(self.__generate_website_location(website, location) for location in website.locations) File "/var/lib/ajenti/plugins/vh-nginx/nginx.py", line 68, in __generate_website_location content = TEMPLATE_LOCATION_CONTENT_PHP7_0_FCGI % { NameError: global name 'TEMPLATE_LOCATION_CONTENT_PHP7_0_FCGI' is not defined