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

I have been trying to install laravel for 3 days on ubuntu 16.04. I am following the top search links of laravel installation process. But I failed to execute each and every process I had tried. Now I am facing a different issue on installing PHP on my ubuntu. I had installed maria db once, but did not succeed. But it might have broken something that resulted in me not being able to install PHP. The issue I am facing:

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).

When I try php -v it gives me this error

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

I am totally new on ubuntu and laravel. And if anyone guide me how to install laravel on ubuntu 16.04 I will be very grateful. Thank You.

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

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

  • chmod +x lemp.sh this command makes bash script executable
  • ./lemp.sh That's it :)

PHP version - v7.0

Mysql version - Latest Stable

Note: Default mysql password is root. you can change it before running in the following lines before running the script

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

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password YOUR_PASSWORD'

Now Install Laravel

  • Go to 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.*"

Try to execute the following commands to solve your problem:

  • Get the list of MySQL packages installed on the system by executing the command sudo dpkg -l | grep mysql

  • Remove the the packages shown above by executing the command sudo apt-get --purge autoremove <packages from the step 1>

  • Delete /var/lib/mysql

  • Try to install mysql again. It should solve your problem