Recentemente uno dei miei clienti ha fornito un nuovo VPS e mi ha chiesto di installare PHP 7, Apache e MySQL. Durante l'installazione di PHP, ho riscontrato il seguente errore:
root@webimage:~# apt-get install php Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php
Soluzione :Per impostazione predefinita PHP5.5 è disponibile solo per Ubuntu Trusty nei repository Ubuntu standard. Quindi, puoi installare la versione PHP 5.5 come mostrato di seguito:
#apt-get install php5
Come installare PHP 7?
Se desideri installare PHP 7 e lo stesso non è disponibile nel repository standard di Ubuntu Trusty. Quindi devi aggiungere il repository corrispondente che include PHP 5.6 e versioni successive.
Aggiungi i seguenti repository nel tuo Ubuntu:
root@webimage:~# add-apt-repository ppa:ondrej/php Co-installable PHP versions: PHP 5.6, PHP 7.0, PHP 7.1 and most requested extensions are included. PLEASE DON'T USE PHP 5.4 OR PHP 5.5. The PHP 5.5 and later are no longer supported with security updates, therefore they are not included in this repository. You can get more information about the packages at https://deb.sury.org BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/ WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround: # LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php More info: https://launchpad.net/~ondrej/+archive/ubuntu/php Press [ENTER] to continue or ctrl-c to cancel adding it gpg: keyring `/tmp/tmp16acixb1/secring.gpg' created gpg: keyring `/tmp/tmp16acixb1/pubring.gpg' created gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com gpg: /tmp/tmp16acixb1/trustdb.gpg: trustdb created gpg: key E5267A6C: public key "Launchpad PPA for OndÅej Surý" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) OK
Devi aggiornare il repository
#apt-get update
Come affermato in precedenza, puoi installare le versioni PHP di 5.6, 7.0 e 7.1 come segue:
Per l'installazione di PHP 5.6
#apt-get install php5.6
Per l'installazione di PHP 7.0
# apt-get install php7.0
Per l'installazione di PHP 7.1
# apt-get install php7.1
Ora puoi iniziare a lavorare con le tue versioni PHP corrispondenti.