ubuntu14 安装apache和php环境

来源:互联网 发布:延安广电网络商务宾馆 编辑:程序博客网 时间:2024/06/06 17:19

第一步:安装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.confInsert the following line at the apache2.conf: ServerName localhostRestart Apache2: apache2ctl restart or /etc/init.d/apache2 restart
但是我本地装了nginx,他可能会出现如下错误:

# /etc/init.d/httpd restartStarting 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:80no listening sockets available, shutting downUnable 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_backupsudo 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
原创粉丝点击