ubuntu18.4 lamp built environment

A, Apache2 web server is installed:

It can update server (optional)

1, sudo apt update # Get the latest Resource Kit

2, sudo apt upgrade # All this software update

3, sudo apt dist-upgrade # software update system of the present

This step may occur the following problems can arise if not ignored:

  Could not get lock /var/lib/dpkg/lock 

  

  Output similar to the following error occurs when you run sudo apt-get XXX this command:

  Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
  Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?
  或者:  

  Could not ge lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)

  Unable to lock directory /var/lib/apt/lists/ 

  Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) 

  Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

  Explain
  this problem occurs because there is a thread in the use of apt-get download operation. But the strange thing is, I just do not find other uses apt-get command terminal interface. Methods So how to solve this problem, do you want to restart the computer, restart the computer that can solve this problem, but I am going to teach you, it is the real solution.

  Solution
  to search for all running threads

  ps aux | grep -i apt

  You'll get something like the following output:

  root 752 0.0 0.0 4508 1628 ? Ss 01:13 0:00 /bin/sh /usr/lib/apt/apt.systemd.daily
  _apt 2098 0.1 0.1 49572 5524 ? S 01:18 0:06 /usr/lib/apt/methods/http
  aobo 4425 0.0 0.0 18484 980 pts/1 S+ 02:13 0:00 grep --color=auto apt


  The first two is the thread number (kill processnumber). We will be apt related processes to close out the need to use sudo permissions:

  Sudo the kill ProcessNumber #
  sudo 2098 the kill
  if there _apt thread and then under examination:

  ps aux | grep -i apt

Prompt, the following operations are carried out by the root authority

# Install Apache

sudo apt install apache2

.... skip the intermediate information

# Check for open Apache, usually installed after the meeting turned on by default.

systemctl status apache2

# Open, close and restart the Apache server

1, systemctl start apache2 # open

2、systemctl stop apache2    # 关闭

3、systemctl restart apache2    # 重启

二、数据库的安装,这里安装MySQL5.7:

# 安装MySQL:

sudo apt install mysql-server-5.7   (这里直接指定版本即可)

sudo service mysql restart/start/stop

就这两个命令就安装好了,可是我在安装过程中并没有出现要我写用户名和密码的地方,我一脸懵逼,
完成后在终端输入mysql -u root -p之后,要求我输入密码,可是我并不知道密码,随便输入之后,

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

打开一个文件

 sudo vim /etc/mysql/debian.cnf
如下

密码会随即给一个很复杂的,这个时候,要进入MySQL的话,就是需要在终端把root更改为debian-sys-maint,如下代码

mysql -u debian-sys-maint -p  AiV62RHXR8cqZROK

这之后就要修改密码了,毕竟密码太难记。

mysql> update mysql.user set authentication_string=password('password') where user='root'and Host = 'localhost';
如果出现下面的提示则成功

成功之后重启mysql服务即可使用root账号进行登录

 

 

通过下列命令安装PHP 7.2

 

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.2
安装对应的php扩展
sudo apt-get install php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml php7.2-intl php7.2-gd php7.2-soap php7.2-gmp php7.2-zip php7.2-imap 
 

安装composer

因为之前我门已经安装过了php的部分扩展所以接下来我们只用安装  curl git unzip这三个东西就行了

如果没有安装,需要安装过php的扩展后再来安装compioser

sudo apt install curl git unzip
 

 

Guess you like

Origin www.cnblogs.com/tyqing/p/11243181.html