您的位置:首页 > 运维架构 > Apache

ubuntu14 安装apache和php环境

2014-12-31 21:48 323 查看
第一步:安装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,我本地是浏览不成功的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: