Ubuntu中Apache運作php-fpm
一、安裝并建立相應軟連接配接
[email protected]:~# apt install apache2 php-fpm
[email protected]:~# cd /etc/apache2/conf-enabled/
[email protected]:/etc/apache2/conf-enabled# ln -sv ../conf-available/php7.2-fpm.conf .
'./php7.2-fpm.conf' -> '../conf-available/php7.2-fpm.conf'
[email protected]:/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
[email protected]:/etc/apache2/conf-enabled# systemctl restart apache2
[email protected]:/etc/apache2/conf-enabled#
Ubuntu Apache 配置注意事項
php-fpm 需要apache 支援proxy_fcgi子產品
apache2 啟用子產品使用 a2enmod 來啟動。
apache2 檢視目前工作模式
[email protected]:/etc/apache2/conf-enabled# a2query -M prefork
[email protected]:/etc/apache2/conf-enabled#
Apache 指令的用法
en是打開,dis是關閉
管理conf 檔案
a2disconf
a2enconf
管理mod
a2dismod
a2enmod
管理站點
a2dissite
a2ensite
範例,啟用關閉proxy_fcgi子產品
[email protected]:/etc/apache2/conf-enabled# a2dismod proxy_fcgi
[email protected]:/etc/apache2/conf-enabled# a2enmod proxy_fcgi
範例,啟用關閉php檔案(其實就是做了軟連接配接,把conf-available裡的檔案連結到enabled)
[email protected]:/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
[email protected]:/etc/apache2/conf-enabled# ll
total 8
drwxr-xr-x 2 root root 4096 Jan 12 08:48 ./
drwxr-xr-x 8 root root 4096 Jan 12 08:21 ../
lrwxrwxrwx 1 root root 30 Jan 8 12:52 charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root 44 Jan 8 12:52 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root 46 Jan 8 12:52 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root 33 Jan 12 08:48 php7.2-fpm.conf -> ../conf-available/php7.2-fpm.conf
lrwxrwxrwx 1 root root 31 Jan 8 12:52 security.conf -> ../conf-available/security.conf
lrwxrwxrwx 1 root root 36 Jan 8 12:52 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf
[email protected]:/etc/apache2/conf-enabled#
[email protected]:/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
[email protected]:/etc/apache2/conf-enabled# ll
total 8
drwxr-xr-x 2 root root 4096 Jan 12 08:53 ./
drwxr-xr-x 8 root root 4096 Jan 12 08:21 ../
lrwxrwxrwx 1 root root 30 Jan 8 12:52 charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root 44 Jan 8 12:52 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root 46 Jan 8 12:52 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root 31 Jan 8 12:52 security.conf -> ../conf-available/security.conf
lrwxrwxrwx 1 root root 36 Jan 8 12:52 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf
[email protected]:/etc/apache2/conf-enabled#