apache2与PHP安装

sudo apt-get update  #更新
sudo apt-get install apache2  #安装

——

/etc/init.d/apache2 start    #启动Apache服务

——

/etc/init.d/apache2 stop    #停止Apache服务

——

/etc/init.d/apache2 restart    #重启Apache服务

Apache的默认文档根目录是在Ubuntu上的/var/www目录

配置文件是/ etc/apache2/apache2.conf

vim /etc/apache2/sites-available/000-default.conf

_

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html    // 一般我们默认为这个作为网站的根目录

_

 vim /etc/apache2/mods-available/dir.conf

_

<IfModule mod_dir.c>
    DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /wordpress
</IfModule>

~

netstat -tnlp #查看端口

~

/etc/init.d/apache2 restart #重启服务

~

vi /etc/apache2/ports.conf #端口配置

PHP安装

sudo apt-get install software-properties-common python-software-properties 

sudo add-apt-repository ppa:ondrej/php && sudo apt-get update

sudo apt-get -y install php7.2

 # 如果之前有其他版本PHP,在这边禁用掉
sudo a2dismod php5
sudo a2enmod php7.2

# 安装常用扩展
sudo -y apt-get install php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml  php7.2-intl 

#  安装其他扩展(按需安装)
sudo apt-get install php7.2-gd
sudo apt-get install php7.2-soap
sudo apt-get install php7.2-gmp    
sudo apt-get install php7.2-odbc       
sudo apt-get install php7.2-pspell     
sudo apt-get install php7.2-bcmath   
sudo apt-get install php7.2-enchant    
sudo apt-get install php7.2-imap       
sudo apt-get install php7.2-ldap       
sudo apt-get install php7.2-opcache
sudo apt-get install php7.2-readline   
sudo apt-get install php7.2-sqlite3    
sudo apt-get install php7.2-xmlrpc
sudo apt-get install php7.2-bz2
sudo apt-get install php7.2-interbase
sudo apt-get install php7.2-pgsql      
sudo apt-get install php7.2-recode     
sudo apt-get install php7.2-sybase     
sudo apt-get install php7.2-xsl
sudo apt-get install php7.2-cgi        
sudo apt-get install php7.2-dba 
sudo apt-get install php7.2-phpdbg     
sudo apt-get install php7.2-snmp       
sudo apt-get install php7.2-tidy       
sudo apt-get install php7.2-zip

_

简易版

sudo apt-get install php7.2
/etc/init.d/apache2 restart    #重启Apache服务加载PHP
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值