初学ubuntu搭建环境

想学习使用ubuntu,准备搭建一个php运行环境,操作了很久没有入门,最后在查询到两篇文章解决了我的问题:

在此感谢提供文章的大佬,

文章地址:https://blog.csdn.net/sunrise_2013/article/details/45922003;

            https://blog.csdn.net/coslay/article/details/22669553

一。安装php

    

1、更新源列表,否则安装php会失败:

命令行输入: vim /etc/apt/source.list

在最前面添加以下内容:

deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse

apt-get update //更新一下列表

2、安装PHP,安装命令:sudoapt-get install php5

3、让Apache支持php,安装命令:sudo apt-get install libapache2-mod-php5

4、安装php5-gd模块,安装命令:sudoapt-get install php5-gd

5、让PHP支持curl

1)首先查看php5-curl是否已安装:dpkg -l | grep 'php5-curl'
2)如果没有安装,则:apt-get install php5-curl

3)确保 extension_dir存在,并且包含curl.so,

查找extension_dirphp -i | grep extension_dir

4)确保 /etc/php5/mods-available/curl.ini存在,文件内容如下:

; configuration for php CURL module
; priority=20
extension=curl.so

二。安装apache

1、安装Apache,安装命令:sudo apt-get install apache2

2、环境配置:

1)配置文件:路径为/etc/apache2,配置文件是apache2.conf,而没有http.conf。

2)默认网站根目录:/var/www/html,使用浏览器访问http://localhost  即可打开;


若出现“It works!”那就说明安装成功了。

安装PHP,并让Apache支持PHP

sudo apt-get install php5 libapache2-mod-php5


安装完成后重启Apache服务器

sudo /etc/init.d/apache2 restart


然后进入Apache的www文件夹下(默认在/var里面),创建phpinfo.php文件

cd /var/www

ls

vi  phpinfo.php

然后在phpinfo.php文件里写入

<?php

phpinfo();

?>

但我们写完后很可能无法保存,因为我们这时对www目录下的文件没有写的权限,因此我们首先对www文件夹下的所有文件授权,然后我们再写入代码。

chmod 777 /var/www/


最后在浏览器里输入http://localhost/phpinfo.php,就可以看到php的信息了


三。安装mysql

1、安装Mysql,安装命令:sudoapt-get install mysql-server,安装过程中设置密码

下图为提示输入数据库密码,然后回车,之后还有提示,再重复输入一次,再回车


最后安装完后进数据库测试一下是否安装成功,看到欢迎信息就ok了

mysql -uroot -p

***


                


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值