一聚教程网:一个值得你收藏的教程网站

热门教程

阿里云Ubuntu14.04安装Apache2.4.7环境的教程

时间:2022-06-30 19:12:34 编辑:袖梨 来源:一聚教程网

在阿里云Ubuntu14.04上安装Apache2.4.7及php5.5.9。

(1) /etc/apt/sources.list

把以下内容填写到/etc/apt/sources.list。

#------------------------------------------------------------------------------#
#                            OFFICIAL UBUNTU REPOS                             #
#------------------------------------------------------------------------------#

###### Ubuntu Main Repos
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse

###### Ubuntu Update Repos
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

###### Ubuntu Partner Repo
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner

###### Ubuntu Extras Repo
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main
修改/etc/apt/sources.list文件之后,执行apt-get update命令。

# apt-get update
~ 省略 ~
Fetched 33.6 MB in 29s (1,122 kB/s)                                           
Reading package lists... Done
W: GPG error: http://extras.ubuntu.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192
如果出现了以上的GPG error的话,执行如下命令之后再次执行apt-get update命令。

# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 16126D3A3E5C1192
最后的16126D3A3E5C1192的部分,修改为NO_PUBKEY后的文字列。

(2) 安装Apache2

apt-get命令安装apache2之后,确认版本。

# apt-get install apache2 -y
# apachectl -v
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jun 29 2016 13:21:39
启动apache2。

# service apache2 start
访问http://IP地址显示如下页面就安装成功apache2了。

Apache2UbuntuDefaultPage

安装php

安装及确认php版本。

# apt-get install libapache2-mod-php5 php5 php5-cli php-pear php5-xcache libapache2-mod-perl2 libapache2-mod-auth-mysql php5-mysql php5-mcrypt

# php -v
PHP 5.5.9-1ubuntu4.18 (cli) (built: Jun  1 2016 12:46:54)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with XCache v3.1.0, Copyright (c) 2005-2013, by mOo
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
    with XCache Optimizer v3.1.0, Copyright (c) 2005-2013, by mOo
    with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo
    with XCache Coverager v3.1.0, Copyright (c) 2005-2013, by mOo
创建info.php文件。

# cat > /var/www/html/info.php <<'EOF'
phpinfo();
?>

EOF


访问http://IP地址/info.php显示如下页面就安装成功php了。

热门栏目