ubuntu14 安装apache和php环境

第一步:安装apache2

sudo apt-get install apache2
可能会出现如下错误:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, 
using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

这个是没有指定ServerName的:http://stackoverflow.com/questions/5856205/starting-httpd-httpd-could-not-reliably-determine-the-servers-fully-qualified

Edit Apache2 conf file : vim /etc/apache2/apache2.conf
Insert the following line at the apache2.conf: ServerName localhost
Restart Apache2: apache2ctl restart or /etc/init.d/apache2 restart
但是我本地装了nginx,他可能会出现如下错误:

# /etc/init.d/httpd restart
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
出现这个情况,有两个解决方案,网上很多关于二者共存的,可是我只是用来学习的,还是用绕道的方式,把apache的端口改掉

http://wiki.ubuntu.com.cn/%E6%94%B9%E5%8F%98Apache%E7%BC%BA%E7%9C%81%E7%AB%AF%E5%8F%A3%E5%8F%B7

sudo cp /etc/apache2/ports.conf /etc/apache2/ports.conf_backup
sudo gedit /etc/apache2/ports.conf

搜寻
Listen 80

替换成
Listen 90

sudo /etc/init.d/apache2 restart

浏览 http://localhost:90/html/出现 It works!  apache安装成功

第二步:安装php环境

 sudo apt-get install libapache2-mod-php5 php5 php5-gd php5-mysql

重启apache:
sudo /etc/init.d/apache2 restart
下面进行测试:
sudo gedit /var/www/html/test.php
添加如下代码:

<?php echo phpInfo();?>
浏览:http://localhost:90/html/test.php

这地方很多博客都在www目录下编辑,浏览也没有html,我本地是浏览不成功的



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值