root@youyou:~# apt install apache2 php-fpm
root@youyou:~# cd /etc/apache2/conf-enabled/
root@youyou:/etc/apache2/conf-enabled# ln -sv ../conf-available/php7.2-fpm.conf .
'./php7.2-fpm.conf' -> '../conf-available/php7.2-fpm.conf'
root@youyou:/etc/apache2/conf-enabled# a2enmod proxy_fcgi
Considering dependency proxy for proxy_fcgi:
Enabling module proxy.
Enabling module proxy_fcgi.
To activate the new configuration, you need to run:
systemctl restart apache2
root@youyou:/etc/apache2/conf-enabled# systemctl restart apache2
root@youyou:/etc/apache2/conf-enabled#
Ubuntu Apache 配置注意事项
- php-fpm 需要apache 支持proxy_fcgi模块
- apache2 启用模块使用 a2enmod 来启动。
- apache2 查看当前工作模式
root@youyou:/etc/apache2/conf-enabled# a2query -M prefork root@youyou:/etc/apache2/conf-enabled#
- Apache 命令的用法,en是打开,dis是关闭
管理conf 文件 :
a2disconf
a2enconf
管理mod:
a2dismod
a2enmod
管理站点:
a2dissite
a2ensite
范例,启用关闭proxy_fcgi模块
范例,启用关闭php文件(其实就是做了软连接,把conf-available里的文件链接到enabled)root@youyou:/etc/apache2/conf-enabled# a2dismod proxy_fcgi root@youyou:/etc/apache2/conf-enabled# a2enmod proxy_fcgi
root@youyou:/etc/apache2/conf-enabled# a2enconf php7.2-fpm Enabling conf php7.2-fpm. To activate the new configuration, you need to run: systemctl reload apache2 root@youyou:/etc/apache2/conf-enabled# ll total 8 drwxr-xr-x 2 root root 4096 Jan 11 08:48 ./ drwxr-xr-x 8 root root 4096 Jan 11 08:21 ../ lrwxrwxrwx 1 root root 30 Jan 8 11:52 charset.conf -> ../conf-available/charset.conf lrwxrwxrwx 1 root root 44 Jan 8 11:52 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf lrwxrwxrwx 1 root root 46 Jan 8 11:52 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf lrwxrwxrwx 1 root root 33 Jan 11 08:48 php7.2-fpm.conf -> ../conf-available/php7.2-fpm.conf lrwxrwxrwx 1 root root 31 Jan 8 11:52 security.conf -> ../conf-available/security.conf lrwxrwxrwx 1 root root 36 Jan 8 11:52 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf root@youyou:/etc/apache2/conf-enabled# root@youyou:/etc/apache2/conf-enabled# a2disconf php7.2-fpm Conf php7.2-fpm disabled. To activate the new configuration, you need to run: systemctl reload apache2 root@youyou:/etc/apache2/conf-enabled# ll total 8 drwxr-xr-x 2 root root 4096 Jan 11 08:53 ./ drwxr-xr-x 8 root root 4096 Jan 11 08:21 ../ lrwxrwxrwx 1 root root 30 Jan 8 11:52 charset.conf -> ../conf-available/charset.conf lrwxrwxrwx 1 root root 44 Jan 8 11:52 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf lrwxrwxrwx 1 root root 46 Jan 8 11:52 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf lrwxrwxrwx 1 root root 31 Jan 8 11:52 security.conf -> ../conf-available/security.conf lrwxrwxrwx 1 root root 36 Jan 8 11:52 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf root@youyou:/etc/apache2/conf-enabled#