ubuntu apache2 相关配置

ubuntu apache2的某些配置

多虚拟主机

  • 所在路径 /etc/apache2/sites-available/000-default.conf
  • 若要修改存放源文件的路径须先修改/etc/apache2/apache2.conf
<Directory /var/www>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>
<VirtualHost *:8080>
   ServerName www.t1.com
   ServerAdmin www.tt1.com
   DocumentRoot /var/www/html8080
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
   ServerName www.t2.com
   ServerAdmin www.tt2.com
   DocumentRoot /var/www/html
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

响应头显示修改

  • 所在路径 /etc/apache2/apache2.conf
ServerSignature Off
ServerTokens Prod

效果如下:在这里插入图片描述

apache2的重启 开始 停止

sudo /etc/init.d/apache2 start/stop/restart

让apache解析html中的php

在/etc/apache2/apache2.conf文件中添加下面两行即可:

AddHandler php-script .php .html
AddType text/html .php .html
# 直接在文本最后添加一行文本
echo 'AddHandler php-script .php .html'>> /etc/apache2/apache2.conf
echo 'AddType text/html .php .htmll'>> /etc/apache2/apache2.conf

LAMP环境搭建

sudo apt install apache2 mysql-server php php-fpm php-cgi php-common php-curl php-mysql  php-mbstring php-xml php-gd -y

php-gd库无法显示图片的一种情况

php-gd库无法显示图片

在生成图片前清空输出缓冲区
ob_clean();
header (‘Content-type: image/png’);
ob_get_contents() - 返回输出缓冲区的内容
ob_flush() - 冲刷出(送出)输出缓冲区中的内容
ob_clean() - 清空(擦掉)输出缓冲区
ob_end_flush() - 冲刷出(送出)输出缓冲区内容并关闭缓冲
ob_end_clean() - 清空(擦除)缓冲区并关闭输出缓冲
flush() - 刷新输出缓冲

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值