Ubuntu下php环境的搭建

一、使用apt-get方式为Ubuntu安装PHP+MYSQL+Apache


(2)安装Apache
  sudo apt-get install apache2

(3)安装PHP
  sudo apt-get install php5
  sudo apt-get install libapache2-mod-auth-mysql
  sudo apt-get install php5-mysql

安装结束后,检测是否成功:

(1)检测Mysql是否正常
  在终端中输入:mysql -uusername -ppassword (将username和password替换为你所设置的)看是否可以正常登陆

(2)检测Apache是否正常
  在浏览器中打开:http://localhost/
  如果出现如下信息,则表明正常。
  It works!
  This is the default web page for this server.
  The web server software is running but no content has been added, yet.

(3)检测PHP是否正常
  Ubuntu下Apache的默认安装路径为/var/www/,到其目录下新建info.php文件,文件内容为:
<?php
phpinfo();
?>
  然后在浏览器中打开:http://localhost/info.php 看是否正常。

注:在该目录直接新建文件是没有权限的,为其增加当前用户权限:
  su root(用root用户)
  chown username /var/www(将username替换为您当前用户的用户名)
  exit(退出root)
 
 
Ubuntu 安装curl

Curl是利用URL语法在命令行方式下工作的文件传输工具,支持很多协议,如HTTP、FTP、TELNET等。在PHP等语言开发的实例中经常使用的到。那么在Lamp服务器上如何安装呢?

以Ubuntu为例,只需一条命令即可:

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

然后重新启动你的服务器:

sudo /etc/init.d/apache2 restart

此时Curl就已经安装完毕了,你可通过包括:<?php phpinfo(); ?>内容的PHP文件来查看安装是否成功了。

 
原文地址:https://www.cnblogs.com/wangfangkui/p/3659289.html