zoukankan      html  css  js  c++  java
  • Ubuntu16.04下搭建LAMP环境

    前期准备
    sudo apt-get update             # 获取最新资源包
    sudo apt-get upgrade           # 本机软件全部更新
    sudo apt-get dist-upgrade    # 本机系统软件更新
    安装Apache
    sudo apt-get install apache2
    检查是否开启Apache,一般安装完会默认开启。
    systemctl status apache2
    开启、关闭和重启服务器
    /etc/init.d/apache2 start
    /etc/init.d/apache2 stop
    /etc/init.d/apache2 restart
    设定开机自启动
    sudo systemctl enable apache2
    安装MariaDB
    安装命令
    sudo apt-get install mariadb-server-10.0 mariadb-client-10.0
    注意按时安装MariaDB的时候如果写mariadb-server的话会出现错误,注意要写上mariadb-server-10.0。
    配置Mariadb的安全选项命令
    sudo mysql_secure_installation
    设定新密码需要输入,其余回车即可Enter current password for root (enter for none): 当前root的密码,直接回车,因为新数据库没有密码。Set root password? [Y/n] 回车,默认为输入Y。New password: 输入新密码Re-enter new password 再次输入新密码Remove anonymous users? [Y/n] 移除匿名用户Disallow root login remotely? [Y/n] 禁止root远程登录Remove test database and access to it? [Y/n] 移除测试数据库Reload privilege tables now? [Y/n] 重新加载权限表
    数据库测试
    mysql -uroot -p
    如果显示Welcome以及Mariadb的版本说明安装成功了。
    安装PHP
    首先安装依赖包
    sudo apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-mbstring php7.0-gd php7.0-json php7.0-curl libapache2-mod-php7.0
    注:这时候可能会报错,会提示下面这条错误
    E: Failed to fetch http://124.205.69.167/files/6040000002C95AB3/packages.deepin.com/deepin/pool/main/t/tiff/libtiff5_4.0.6-1_amd64.deb  Writing more data than expected (143936 > 143776)
    E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
    你需要做的是sudo apt-get update一下,更新软件资源。然后再次执行此命令即可安装成功。
    启用Apache的php7.0的安装模块,并重启Apache
    sudo a2enmod php7.0
    sudo systemctl restart apache2
    启用php7.0-fpm进程
    sudo systemctl start php7.0-fpm
    测试PHP,查看版本
    php --version
    输出phpinfo
    vim /var/www/html/phpinfo.php
    写入如下内容
    <?php
      echo phpinfo();
    ?>
    在浏览器输入服务器IP/phpinfo.php,如192.168.0.1/phpinfo.php服务器IP用ifconfig查看。
  • 相关阅读:
    85. Maximal Rectangle
    120. Triangle
    72. Edit Distance
    39. Combination Sum
    44. Wildcard Matching
    138. Copy List with Random Pointer
    91. Decode Ways
    142. Linked List Cycle II
    异或的性质及应用
    64. Minimum Path Sum
  • 原文地址:https://www.cnblogs.com/linuxzxy/p/6519471.html
Copyright © 2011-2022 走看看