美文网首页
Ubuntu16.04上安装LAMP

Ubuntu16.04上安装LAMP

作者: snowy_sunny | 来源:发表于2017-07-17 10:45 被阅读0次

以下是Ubuntu下两种安装LAMP的方法,推荐使用第一种方法,简单高效,第二种方法的优势是可以按照自己的需求选择相应的版本。

方法一(推荐):

1.安装Apache

sudo apt-get install apache2

  • 测试: 浏览器访问http://Ubuntu的IP,出现It Works!网页。
  • 查看状态: service apache2 status/start/stop/restart
  • Web目录: /var/www
  • 安装目录: /etc/apache2/
  • 全局配置: /etc/apache2/apache2.conf
  • 监听端口: /etc/apache2/ports.conf
  • 虚拟主机: /etc/apache2/sites-enabled/000-default.conf

2.安装MySQL

sudo apt-get install mysql-server mysql-client

  • 测试: mysql -u root -p
  • 查看状态: service mysql status/start/stop/retart
  • 查看监听端口的情况: netstat -tunpl 或 netstat -tap

3.安装PHP

sudo apt-get install php7.0

  • 测试: php7.0 -v

4.安装其他模块

sudo apt-get install libapache2-mod-php7.0
sudo apt-get install php7.0-mysql

  • 重启服务
  • service apache2 restart
  • service mysql restart
  • 测试Apache能否解析PHP
  • vim /var/www/html/phpinfo.php
  • 文件中写:<?php echo phpinfo();?>
  • 浏览器访问:http://ubuntu地址/phpinfo.php,出现PHP Version网页

5.修改权限

sudo chmod 777 /var/www

6.安装phpMyAdmin

sudo apt-get install phpmyadmin

  • 安装: 选择apache2,点击确定。下一步选择是要配置数据库,并输入密码。
  • 创建phpMyAdmin快捷方式:
    sudo ln -s /usr/share/phpmyadmin /var/www/html
  • 启用Apache mod_rewrite模块: sudo a2enmod rewrite
  • 重启服务:
  • service php7.0-fpm restart
  • service apache2 restart

7.配置Apache

vim /etc/apache2/apache2.conf

  • 添加:
  • AddType application/x-httpd-php .php .htm .html
  • AddDefaultCharset UTF-8
  • 重启Apache服务

方法二:

安装apache:http://blog.csdn.net/forrest_ou/article/details/60769087
安装php:http://blog.csdn.net/forrest_ou/article/details/60780218
同时参照:http://www.bkjia.com/Linuxjc/1096474.html

Paste_Image.png

相关文章

网友评论

      本文标题:Ubuntu16.04上安装LAMP

      本文链接:https://www.haomeiwen.com/subject/uvgvzttx.html