为什么我无法在Ubuntu 16.04上安装PHP

时间:2018-08-31 05:57:51

标签: php mysql laravel ubuntu-16.04

我一直试图在ubuntu 16.04上安装laravel 3天。我正在关注laravel安装过程的顶部搜索链接。但是我无法执行我尝试过的每个过程。现在,我在ubuntu上安装PHP时遇到了另一个问题。我曾经安装过maria db,但没有成功。 但是它可能损坏了某些东西,导致我无法安装PHP。我面临的问题:

Reading package lists... Done 
Building dependency tree       
Reading state information... Done
php is already the newest version (1:7.2+62+ubuntu16.04.1+deb.sury.org+3).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
mysql-server : Depends: mysql-server-5.7 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

当我尝试php -v时,会出现此错误

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718//usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718//usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.2.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 19 2018 07:16:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

我对ubuntu和laravel完全陌生。如果有人指导我如何在ubuntu 16.04上安装laravel,我将不胜感激。 谢谢。

2 个答案:

答案 0 :(得分:2)

  • 安装git apt-get install git-core
  • git clone https://github.com/thamaraiselvam/LEMP-Stack-Installer.git

  • cd quick-lemp-install或cd LEMP-Stack-Installer

  • chmod +x lemp.sh此命令使bash脚本可执行
  • ./lemp.sh 就是这样:)
  

PHP版本-v7.0

     

MySQL版本-最新稳定版

     

注意:默认的mysql密码是root。您可以在运行前更改它   在运行脚本之前在以下几行中

     

sudo debconf-set-selections <<<'mysql-server   mysql-server / root_password密码YOUR_PASSWORD'

     

sudo debconf-set-selections <<<'mysql-server   mysql-server / root_password_again再次输入密码YOUR_PASSWORD'

现在安装Laravel

  • 转到cd /var/www/html/
  • sudo apt-get install php-common php-mbstring php-xml php-zip
  • composer create-project --prefer-dist laravel/laravel blog "5.5.*"

答案 1 :(得分:1)

尝试执行以下命令来解决您的问题:

  • 通过执行以下命令获取系统上安装的MySQL软件包的列表 命令sudo dpkg -l | grep mysql

  • 通过执行命令sudo apt-get --purge autoremove <packages from the step 1>

  • 删除上面显示的软件包
  • 删除/var/lib/mysql

  • 尝试再次安装mysql。它应该可以解决您的问题