ubuntu LAMP 安装及配置

来源:互联网 发布:linux 文件修改时间 编辑:程序博客网 时间:2024/05/20 21:48

安装环境:    Linux xyz 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux



安装块:



1.  安装 apache2


  sudo apt-get install apache2                  #安装apache2


2. 安装 php5


   sudo apt-get install     php5     libapache2-mod-php5     php5-gd    php5-mysql     
   #libapache2-mod-php5让apache能够解析php5   #php5-mysql是php5的数据库的扩展,提供php能够使用的访问接口



3. 安装 mysql

   

    sudo apt-get install mysql-server mysql-client    
    #安装mysql的客户端和服务端    #安装过程中会提示设置mysql的密码. 



4. 安装 phpmyadmin-mysql 数据库图形化管理


    sudo  apt-get install phpmyadmin
    sudo ln -s /usr/share/phpmyadmin /var/www    # phpmyadmin和www建立连接

     #在安装过程中会要求选择Web server:apache2或lighttpd,使用空格键选定apache2,按tab键然后确定。

     #然后会要求输入设置的Mysql数据库密码



5. www读写权限

     
    sudo chmod 777 /var/www     #给web目录设置可读写可执行权限 drwxrwxrwx 3 root root 4096 Nov  5 11:42 www/

配置块:

 配置php.ini  <纯个人经验>

       我刚开始在写 php代码时,很爽,因为刚开始学,写的代码很少,也很少出错,后来代码量变大了,代码很容易出错了,当时我调试只会用echo输出,结果可想而知,非常难以调试,后来查了很多资料,终于知道了方法,现在分享给大家!

 需要配置的文件  php.ini , 如果你不知道php.ini在哪,可以  locate   php.ini   找一下。

调试 php 程序跟这两个变量有关   

display_errors = error_reporting =
xyz@Gentoo:/etc/php5/apache2$ sudo vim php.ini         # 用vim 编辑 php.ini



这两个变量的默认值是


error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICTdisplay_errors = Off                    #只把这个变量的值改成 On 就可以了
; 下面是注释
; This directive controls whether or not and where PHP will output errors,; notices and warnings too. Error output is very useful during development, but; it could be very dangerous in production environments. Depending on the code; which is triggering the error, sensitive information could potentially leak; out of your application such as database usernames and passwords or worse.; It's recommended that errors be logged on production servers rather than; having the errors sent to STDOUT.; Possible Values:;   Off = Do not display any errors;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!);   On or stdout = Display errors to STDOUT; Default Value: On; Development Value: On; Production Value: Off

看注释就可以知道,把 display_errors 这个变量的值改成 On 就可以了.
至于为什么 display_errors 的默认值是 Off  , 是怕出错信息中包含敏感信息(用户, 密码, 数据库) 。



<<<<<<<<<<<<<<<<<<<           安装配置完成           >>>>>>>>>>>>>>>>>>>>>>>>


sudo    reboot   #现在重启下吧


 现在在浏览器里输入http://localhost  或者是 http://127.0.0.1


打开127.0.0.1时会默认打开 index. *文件.


在浏览器里输入  127.0.0.1/phpmyadmin  可以图形化管理 MySql 数据库


Apache的默认安装,会在/var下建立一个名为www的目录,这个就是Web目录了,所有要能过浏览器访问的Web文件都要放到这个目录里。




原创粉丝点击