zoukankan      html  css  js  c++  java
  • Ubuntu 12.04 之 LAMP

    搭建LAMP环境


     (1)更新软件列表:

      sudo apt-get update

      结果报错:

    W: 无法下载 bzip2:/var/lib/apt/lists/partial/cn.archive.ubuntu.com_ubuntu_dists_precise_universe_binary-i386_Packages  Hash 校验和不符
    
    W: 无法下载 bzip2:/var/lib/apt/lists/partial/cn.archive.ubuntu.com_ubuntu_dists_precise_multiverse_binary-i386_Packages  Hash 校验和不符
    
    W: Some index files failed to download. They have been ignored, or old ones used instead.

      第一次尝试修改软件源: 

        点击【Ubuntu 软件中心】--> 左上角【编辑】-->下拉列表的【软件源】,修改之后还是不行。

      第二次尝试: 

        sudo rm -r /var/lib/apt/lists/partial/*  
        sudo rm -r /var/lib/apt/lists/*
        sudo apt-get update
        更新完成。
    参考文章:https://blog.csdn.net/super_mimi/article/details/40628887

    (2)安装apache:

      安装apache:

    sudo apt-get install apache2

      查看apahce版本

    test@localhost:~$ apache2 -v
    Server version: Apache/2.2.22 (Ubuntu)
    Server built:   Jul 15 2016 15:32:45

      访问ip地址:

    It works!
    
    This is the default web page for this server.
    
    The web server software is running but no content has been added, yet.

    说明apache正常运行了。


    (3)安装PHP 

    sudo apt-get install php5

    查看php版本:

    test@localhost:~$ php5 -v
    PHP 5.3.10-1ubuntu3.26 with Suhosin-Patch (cli) (built: Feb 13 2017 20:37:53) 
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

    php安装成功。


     (4)查看apache是否加载php

    test@localhost:~$ cat /etc/apache2/mods-enabled/php5.load
    LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
    libphp5.so被apache加载了

    (5)安装mysql

    sudo apt-get install mysql-server

    (6)检查php是否加载mysql

    test@localhost:~$ cat /etc/php5/conf.d/mysql.ini
    cat: /etc/php5/conf.d/mysql.ini: 没有那个文件或目录

    没有msql.so,说明mysql没有被正确加载。

    php默认不安装MySQL扩展,需要手动安装:

    sudo apt-get install php5-mysql

    再次检查是否加载:

    test@localhost:~$ cat /etc/php5/conf.d/mysql.ini
    ; configuration for php MySQL module
    extension=mysql.so

    加载成功。


    (7)测试环境是否正常:

    重启一下mysql:

    test@localhost:~$ sudo service mysql restart
    mysql stop/waiting
    mysql start/running, process 7503

    重启apache:

    test@localhost:~$ sudo service apache2 restart
     * Restarting web server apache2                                                        apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
     ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                                     [ OK ]

    默认web目录在 /var/www下。

    编辑phpinfo文件测试,进入/var/www目录:

    sudo vim phpinfo.php(如果没有vim,安装vim:sudo apt-get install vim)

    内容:

    <?php
        echo mysql_connect('localhost','root','123456')?'db success':'db fail';
    
        phpinfo();

    然后访问这个文件,IP地址/phpinfo.php。

    可以看到db success和phpinfo信息,表示搭建成功。


     (8)安装常用扩展

    sudo apt-get install php5-gd curl libcurl3 libcurl3-dev php5-curl

    需要重启apache,sudo service apache2 restart


    (9)其他方式搭建环境:

    方法一:

      可以使用一条命令安装所有软件:

      sudo apt-get install apache2 php5 mysql-server php5-mysql 。

    方法二:

      使用tasksel工具安装:

      sudo tasksel install lamp-server


     (10)安装phpmyadmin

    apt-get 方式:

      sudo apt-get install phpmysadmin

      sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin

    手动上传:

      在电脑上下载phpmyadmin,然后上传到服务器上。

  • 相关阅读:
    MiniGUI
    Android-在XML和Java代码中设置背景在不同状态的效果: <selector>/StateListDrawable
    URLEncoder.encode、URLDecoder.decode、escape、encodeURI、encodeURIComponent
    getDimension,getDimensionPixelOffset和getDimensionPixelSize的一点说明
    Android获取屏幕分辨率及DisplayMetrics简介
    细说Android事件传递机制(dispatchTouchEvent、onInterceptTouchEvent、onTouchEvent)
    Android
    Android坐标
    Android Sqlite IN, NOT IN syntax --- not int (?)
    TextView with SingleLine as true and Gravity as Center not passing the events to the ViewPager if it has a Click Event
  • 原文地址:https://www.cnblogs.com/gyfluck/p/9335615.html
Copyright © 2011-2022 走看看