Ubuntu16.04 搭建LAMP环境
2017-08-14 19:36
411 查看
更新
sudo apt-get update
完成
Fetched 35.8 MB in 8s (4,233 kB/s) Reading package lists... Done
安装Apache2
sudo apt-get install apache2
完成
Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for systemd (229-4ubuntu18) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for ufw (0.35-0ubuntu2) ...
输入命令
apachectl -v
可以看到当前apache版本
Server version: Apache/2.4.18 (Ubuntu) Server built: 2017-07-27T14:34:01
访问服务器IP , 出现It works! 则表示安装成功
安装MySql
sudo apt-get install mysql-server mysql-client
安装完成
Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for systemd (229-4ubuntu18) ... Processing triggers for ureadahead (0.100.0-19) ...
尝试登陆下数据库 输入命令
mysql -u root -p
输入密码之后按回车
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
安装PHP
sudo apt-get install php
安装完成
Creating config file /etc/php/7.0/fpm/php.ini with new version Setting up php7.0 (7.0.22-0ubuntu0.16.04.1) ... Setting up php (1:7.0+35ubuntu6) ... Processing triggers for systemd (229-4ubuntu18) ... Processing triggers for ureadahead (0.100.0-19) ...
输入命令
php -v
可以看到PHP的版本
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
安装其他模块
sudo apt-get install libapache2-mode-php sudo apt-get install php-mysql
重启服务
sudo service mysql restart sudo service apache2 restart
测试
创建一个文件vim /var/www/html/phpinfo.php
内容为
<?php echo phpinfo(); ?>
浏览器访问http://ip地址/phpinfo.php
修改权限
/var/www sudo chomod 777 /var/www
安装phpMyAdmin
sudo apt-get install phpmyadmin
Processing triggers for libc-bin (2.23-0ubuntu9) ... Processing triggers for libapache2-mod-php7.0 (7.0.22-0ubuntu0.16.04.1) ... Processing triggers for php7.0-fpm (7.0.22-0ubuntu0.16.04.1) ...
创建快捷方式
sudo ln -s /usr/share/phpmyadmin /var/www/html
启用Apache mod_rewrite模块
sudo a2enmod rewrite
重启服务
sudo service php7.0-fpm restart sudo service apache2 restart
访问浏览器 http://ip地址/phpmyadmin
sudo时出现sudo: unable to resolve host xxxx
执行sudo时发现会出警告sudo: unable to resolve host
解决办法
vim /etc/hosts
原始内容为
127.0.0.1 localhost # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
在127.0.0.1 localhost后加上当前主机名称即可 , 如
127.0.0.1 localhost xxxx
相关文章推荐
- Ubuntu 16.04 apt-get搭建LAMP环境
- Ubuntu 16.04搭建LAMP开发环境
- Ubuntu 16.04搭建LAMP开发环境
- Ubuntu 16.04 apt-get搭建LAMP环境
- 最新Linux系统Ubuntu16.04搭建HUSTOJ(LAMP环境)
- Ubuntu 16.04 apt-get搭建LAMP环境
- Ubuntu 16.04 apt-get搭建LAMP环境
- ubuntu16.04 搭建PHP开发环境LAMP
- Ubuntu 16.04 apt-get搭建LAMP环境
- Ubuntu 16.04 搭建LAMP开发环境
- Ubuntu 16.04 apt-get搭建LAMP环境
- Ubuntu 16.04 apt-get搭建LAMP环境
- Ubuntu 16.04 apt-get搭建LAMP环境
- Ubuntu 16.04 搭建LAMP服务器环境流程
- Ubuntu16.04搭建LAMP环境详细教程
- Ubuntu 16.04搭建LAMP开发环境
- Ubuntu 16.04搭建LAMP开发环境
- Ubuntu 16.04 apt-get搭建LAMP环境
- Ubuntu 16.04搭建LAMP开发环境
- [PHP] ubuntu16.04配置Lamp环境(搭建linux+apache+mysql+php7环境)