linux上开发系列之安装LAMP

Ubuntu 系统

安装APACHE

$ sudo apt install apache2
OR
$ sudo apt-get install apache2

重启服务:

$ sudo systemctl status apache2.service 
$ sudo netstat –tlpn

如图:
Apache-Default-Page.png

安装php


开启ssl:

$ sudo a2enmod ssl
$ sudo a2ensite default-ssl.conf
$ sudo systemctl restart apache2.service

查看ssl 端口

sudo netstat -tlpn



### 首先增加php7 仓库

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php-7.0


### 移除php5,安装php7

安装前做好 配置文件备份工作。


<!--more-->

sudo apt-get update && sudo apt-get purge php5-fpm && sudo apt-get --purge autoremove && sudo apt-get install php7.0-fpm php7.0-mysql


### 禁用php5

sudo a2dismod php5

参考php5,创建php7配置文件

sudo cp /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php7.conf
sudo a2enmod php7
sudo service apache2 restart


## php7 curl 安装

sudo apt-get install php7.0-curl

重启Apache

$ sudo systemctl restart apache2

## 安装MariaDB 

$ sudo apt install php7.0-mysql mariadb-server mariadb-client


配置MariaDB

sudo mysql_secure_installation


![Secure-MariaDB-in-Ubuntu-16.04.png][2]

连接数据库:

$ sudo mysql
MariaDB> use mysql;
MariaDB> update user set plugin='' where User='root';
MariaDB> flush privileges;
MariaDB> exit


如图:

![Assign-User-Permissions-to-MariaDB.png][3]

重启mysql:

$ sudo systemctl restart mysql.service
$ mysql -u root -p

参考:

 - [https://www.linuxbabe.com/linux-server/install-apache-mariadb-and-php7-lamp-stack-on-ubuntu-16-04-lts](https://www.linuxbabe.com/linux-server/install-apache-mariadb-and-php7-lamp-stack-on-ubuntu-16-04-lts)

 - [https://www.linuxbabe.com/linux-server/install-nginx-mariadb-php7-lemp-stack-ubuntu-16-04-lts](https://www.linuxbabe.com/linux-server/install-nginx-mariadb-php7-lemp-stack-ubuntu-16-04-lts)
  [1]: https://kelvin.mbioq.com/usr/uploads/2016/11/4013838999.png
  [2]: https://kelvin.mbioq.com/usr/uploads/2016/11/2079673821.png

添加新评论