1.安装apache2
sudo apt-get update
sudo apt-get install apache2
这时http://你机器的ip,就可以访问了
2.安装php7.0+及一些必要的扩展
apt-get install software-properties-common python-software-properties add-apt-repository ppa:ondrej/php && sudo apt-get update apt-get -y install php7. # 如果之前有其他版本PHP,在这边禁用掉
sudo a2dismod php5
sudo a2enmod php7. # 安装常用扩展
sudo -y apt-get install php7.-fpm php7.-mysql php7.-curl php7.-json php7.-mbstring php7.-xml php7.-intl # 安装其他扩展(按需安装)
sudo apt-get install php7.-gd
sudo apt-get install php7.-soap
sudo apt-get install php7.-gmp
sudo apt-get install php7.-odbc
sudo apt-get install php7.-pspell
sudo apt-get install php7.-bcmath
sudo apt-get install php7.-enchant
sudo apt-get install php7.-imap
sudo apt-get install php7.-ldap
sudo apt-get install php7.-opcache
sudo apt-get install php7.-readline
sudo apt-get install php7.-sqlite3
sudo apt-get install php7.-xmlrpc
sudo apt-get install php7.-bz2
sudo apt-get install php7.-interbase
sudo apt-get install php7.-pgsql
sudo apt-get install php7.-recode
sudo apt-get install php7.-sybase
sudo apt-get install php7.-xsl
sudo apt-get install php7.-cgi
sudo apt-get install php7.-dba
sudo apt-get install php7.-phpdbg
sudo apt-get install php7.-snmp
sudo apt-get install php7.-tidy
sudo apt-get install php7.-zip
3.修改默认主页
修改 /etc/apache2/mods-enabled/dir.conf
把DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm中index.php改到最前面(可以根据自已需要)
如:DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
4.重启apache2让修改生效,并测试
重启apache2:sudo service apache2 restart
ubuntu14.04中apache的网站主目录是在:/var/www/html
在此目录新建info.php文件,内容为:
<?php
phpinfo();
?>
访问:重启apache服务器后,访问url= http://你服务器ip/info.php 如果显示php环境信息,测表示安装成功