Home >php教程 >php手册 >Ubuntu下快速安装php环境

Ubuntu下快速安装php环境

WBOY
WBOYOriginal
2016-06-06 19:47:15794browse

今天蛋疼了一下,在Ubuntu下装了一下php的环境,也就是装了一下MySQL、PHP、Apache。话说还真是简单。。。不禁让我想起原来在windows下开发的时候撑死就是装不上,而且一个就是几个G。。。最后还是用了easyPHP(但是真心好用啊,强烈推荐) Ubuntu强大的包管

今天蛋疼了一下,在Ubuntu下装了一下php的环境,也就是装了一下MySQL、PHP、Apache。话说还真是简单。。。不禁让我想起原来在windows下开发的时候撑死就是装不上,而且一个就是几个G。。。最后还是用了easyPHP(但是真心好用啊,强烈推荐)

Ubuntu强大的包管理工具让我们通过几条命令就能安装好环境

<span><span> 1</span> <span>#安装mysql
</span><span> 2</span> 
<span> 3</span> <span>sudo</span> apt-get <span>install</span> mysql-<span>server
</span><span> 4</span> 
<span> 5</span> <span>#这个完成后会有一个要求输入root用户密码的部分
</span><span> 6</span> 
<span> 7</span> <span>sudo</span> apt-get <span>install</span> mysql-<span>client
</span><span> 8</span> 
<span> 9</span> <span>#安装apache
</span><span>10</span> 
<span>11</span> <span>sudo</span> apt-get <span>install</span><span> apache2
</span><span>12</span> 
<span>13</span> <span>#安装php
</span><span>14</span> 
<span>15</span> <span>sudo</span> apt-get <span>install</span><span> php5
</span><span>16</span> 
<span>17</span> <span>#安装连接关系(直接都配置好了,windows下改这个改那个的情况完全不用担心)
</span><span>18</span> 
<span>19</span> <span>sudo</span> apt-get <span>install</span> libapache2-mod-auth-<span>mysql
</span><span>20</span> 
<span>21</span> <span>sudo</span> apt-get <span>install</span> php5-mysql</span>

 

然后就是检测成果了:

在浏览器输入localhost看到如下界面就说明Apache安装成功了

Ubuntu下快速安装php环境

在终端输入

mysql -username –password

成功登陆就是mysql成功率。

检验php由于权限问题稍微麻烦一点,Apache的的默认安装路径为/var/www/。我们需要到其下建立一个php文件,但是用户是没有权限的,首先我们要获得权限:

su root
chown username /var/www

然后写个php文件输出phpinfo

文件如下:

<span><span>php
</span><span>phpinfo</span><span>();
</span>?></span>

 

成功看到的界面为:

Ubuntu下快速安装php环境

至此环境的配置就完成了,so easy~~~

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn