- How To Install mod_fcgid on CentOS 8
- What is mod_fcgid
- Install mod_fcgid on CentOS 8 Using dnf
- Install mod_fcgid on CentOS 8 Using yum
- How To Uninstall mod_fcgid on CentOS 8
- mod_fcgid Package Contents on CentOS 8
- References
- Summary
- Добавление дополнительной версии PHP в веб-сервер Apache на CentOS 7
- Установка еще одной версии PHP
- How to Setup Apache with PHP/FastCGI on CentOS/RHEL 7/6
- Step 1 – Prerequsitis
- Step 2 – Install Apache2
- Step 3 – Install PHP and FastCGI
- Step 4 – Disable Default PHP Handler
- Step 5 – Setup FastCGI Handler
- Step 6 – Setup VirtualHost with FastCGI
- Step 7 – Restart Apache and Test Setup
- Installing and Configuring FastCGI and PHP-FPM on CentOS 8
- Before You Begin
- Install mod_fcgid and PHP-FPM
- Configure Apache with PHP-FPM
How To Install mod_fcgid on CentOS 8
In this tutorial we learn how to install mod_fcgid on CentOS 8.
What is mod_fcgid
mod_fcgid is a binary-compatible alternative to the Apache module mod_fastcgi. mod_fcgid has a new process management strategy, which concentrates on reducing the number of fastcgi servers, and kicking out corrupt fastcgi servers as soon as possible.
We can use yum or dnf to install mod_fcgid on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install mod_fcgid.
Install mod_fcgid on CentOS 8 Using dnf
Update yum database with dnf using the following command.
sudo dnf makecache --refresh
The output should look something like this:
CentOS Linux 8 - AppStream 43 kB/s | 4.3 kB 00:00 CentOS Linux 8 - BaseOS 65 kB/s | 3.9 kB 00:00 CentOS Linux 8 - ContinuousRelease 43 kB/s | 3.0 kB 00:00 CentOS Linux 8 - Extras 23 kB/s | 1.5 kB 00:00 CentOS Linux 8 - FastTrack 40 kB/s | 3.0 kB 00:00 CentOS Linux 8 - HighAvailability 36 kB/s | 3.9 kB 00:00 CentOS Linux 8 - Plus 24 kB/s | 1.5 kB 00:00 CentOS Linux 8 - PowerTools 50 kB/s | 4.3 kB 00:00 Extra Packages for Enterprise Linux Modular 8 - x86_64 13 kB/s | 9.2 kB 00:00 Extra Packages for Enterprise Linux 8 - x86_64 24 kB/s | 8.5 kB 00:00 Metadata cache created.
After updating yum database, We can install mod_fcgid using dnf by running the following command:
sudo dnf -y install mod_fcgid
Install mod_fcgid on CentOS 8 Using yum
Update yum database with yum using the following command.
sudo yum makecache --refresh
The output should look something like this:
CentOS Linux 8 - AppStream 43 kB/s | 4.3 kB 00:00 CentOS Linux 8 - BaseOS 65 kB/s | 3.9 kB 00:00 CentOS Linux 8 - ContinuousRelease 43 kB/s | 3.0 kB 00:00 CentOS Linux 8 - Extras 23 kB/s | 1.5 kB 00:00 CentOS Linux 8 - FastTrack 40 kB/s | 3.0 kB 00:00 CentOS Linux 8 - HighAvailability 36 kB/s | 3.9 kB 00:00 CentOS Linux 8 - Plus 24 kB/s | 1.5 kB 00:00 CentOS Linux 8 - PowerTools 50 kB/s | 4.3 kB 00:00 Extra Packages for Enterprise Linux Modular 8 - x86_64 13 kB/s | 9.2 kB 00:00 Extra Packages for Enterprise Linux 8 - x86_64 24 kB/s | 8.5 kB 00:00 Metadata cache created.
After updating yum database, We can install mod_fcgid using yum by running the following command:
sudo yum -y install mod_fcgid
How To Uninstall mod_fcgid on CentOS 8
To uninstall only the mod_fcgid package we can use the following command:
sudo dnf remove mod_fcgid
mod_fcgid Package Contents on CentOS 8
/etc/httpd/conf.d/fcgid.conf /etc/httpd/conf.modules.d/10-fcgid.conf /run/mod_fcgid /usr/lib/.build-id /usr/lib/.build-id/3d /usr/lib/.build-id/3d/4c5c08b3ddd2dbdca58ffe3a50a2280bcf8a59 /usr/lib/tmpfiles.d/mod_fcgid.conf /usr/lib64/httpd/modules/mod_fcgid.so /usr/share/doc/mod_fcgid /usr/share/doc/mod_fcgid/CHANGES-FCGID /usr/share/doc/mod_fcgid/ChangeLog /usr/share/doc/mod_fcgid/NOTICE-FCGID /usr/share/doc/mod_fcgid/README-FCGID /usr/share/doc/mod_fcgid/STATUS-FCGID /usr/share/doc/mod_fcgid/fixconf.sed /usr/share/doc/mod_fcgid/mod_fcgid.html.en /usr/share/licenses/mod_fcgid /usr/share/licenses/mod_fcgid/LICENSE-FCGID
References
Summary
In this tutorial we learn how to install mod_fcgid on CentOS 8 using yum and dnf.
Добавление дополнительной версии PHP в веб-сервер Apache на CentOS 7
Обновлено: 17.10.2022 Опубликовано: 03.07.2019
Тематические термины: PHP, Apache, CentOS, веб-сервер. В большинстве случаев, для индивидуального использования веб-сервера, достаточно одной версии PHP. Но на хостингах или при ведении нескольких проектов, написанных на разных версиях PHP, необходимо, чтобы виртуальные домены сервера могли поддерживать разные версии интерпретатора. В данной инструкции рассмотрена настройка на примере веб-сервера Apache, работающего на операционной системе Linux CentOS 7. Подразумевается, что сам веб сервер настроен, например, по статье Как настроить полноценный веб-сервер на CentOS. После конфигурирования у нас будет две версии php на одном сервере Apache.
Установка еще одной версии PHP
Предположим, на нашем сервере уже установлен PHP версии 5.4.16. Добавим PHP 5.2.17 (также протестировано с версией 7.4.30). Устанавливаем пакеты, которые нам понадобятся для сборки интерпретатора:
yum install wget libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel bzip2-devel freetype-devel aspell-devel uw-imap-devel libmcrypt-devel libmhash-devel mysql-devel postgresql-devel gcc
* данный набор пакетов не является полным. Например, для PHP версии 7 или для установки дополнительных модулей могут потребоваться другие пакеты. Тут уже нужно ориентироваться по ситуации — получив ошибку при конфигурировании, найти описании проблемы и выполнить соответствующую установку. Создаем каталог для исходников:
Так как в нашем примере мы устанавливаем PHP 5, переходим по соответствующей ссылке и копируем путь для загрузки исходника:
. используя ссылку, скачиваем исходник на сервер:
* если CentOS вернет ошибку, необходимо установить wget командой yum install wget.
Для удобства, сохраняем устанавливаемую версию PHP в переменную:
Создаем каталог для установки PHP:
Распаковываем скачанный исходник:
После переходим в каталог с распакованными файлами:
./configure —prefix=/opt/php-$PHP_VER —with-config-file-path=/opt/php-$PHP_VER —with-pdo-pgsql —with-zlib-dir —with-freetype-dir —enable-mbstring —with-libxml-dir=/usr —enable-soap —enable-calendar —with-curl=/usr/bin —with-mcrypt —with-zlib —with-gd —with-pgsql —disable-rpath —enable-inline-optimization —with-bz2 —with-zlib —enable-sockets —enable-sysvsem —enable-sysvshm —enable-pcntl —enable-mbregex —with-mhash —enable-zip —with-pcre-regex —with-mysql —with-pdo-mysql —with-mysqli —with-jpeg-dir=/usr/lib64 —with-libdir=lib64 —with-png-dir=/usr —enable-gd-native-ttf —with-openssl —enable-ftp —with-imap —with-imap-ssl —with-kerberos —with-gettext —enable-cli —enable-fastcgi —enable-discard-path —enable-force-cgi-redirect —enable-cgi —enable-bcmath
* при конфигурировании, мы можем получить различные ошибки, связанные с нехваткой компонентов. Для решения данного типа проблем, необходима установка дополнительных пакетов. Что это за пакеты — необходимо разобраться самостоятельно.
Также мы, скорее всего, столкнемся с предупреждением configure: WARNING: unrecognized options. Это значит, что некоторые опции не отработали. Такое случается, так как от версии к версии некоторые из них больше не работают или имеют немного другое написание, например не —with-gd, а —enable-gd. Изучите предупреждение и исправьте недочеты.
Собираем пакет и устанавливаем его:
How to Setup Apache with PHP/FastCGI on CentOS/RHEL 7/6
FastCGI functionality is very similar to working of CGI. FastCGI makes differences at few places than CGI like FastCGI processes are persistent and they can handle more than one request per process. FastCGI allows running programs on remote machines by multiplexes the environment information, standard input, output and error over a single full-duplex connection. Read more about FastCGI.
This tutorial will help you to set up Apache webserver with PHP and FastCGI on RedHat based systems.
Step 1 – Prerequsitis
Fast of all, enable REMI and EPEL yum repositories on your system. These repositories provide the lastest packages for RedHat based systems.
Step 2 – Install Apache2
Apache2 packages are available with the name HTTPD for Redhat based systems. You can use the following commands to install the latest available Apache2 (HTTPD) packages in configured repositories on your system.
Step 3 – Install PHP and FastCGI
After installing the Apache web server, let’s install PHP and FastCGI Apache module on your system. You can install any version of the required PHP or simply use the following command to install available PHP packages. This tutorial doesn’t include installing PHP modules, So you can also install required PHP modules.
yum install php php-cli mod_fcgid
Step 4 – Disable Default PHP Handler
Before using PHP/FastCGI handler, you have to disable the default PHP handler on your system. Edit PHP configuration file for Apache (/etc/httpd/conf.d/php.conf) in your favorite text editor and comment following lines showing in below screenshot by adding the hash (#) sign at the start of the lines.
Step 5 – Setup FastCGI Handler
At this point we have successfully installed Apache FastCGI Module. Now nagigate to /var/www/cgi-bin directory, If not exists create directory. Then create a php.fastcgi file and add the following content to this file. Also make sure the php.ini file and php-cgi exist on your system.
vim /var/www/cgi-bin/php.fastcgi
#!/bin/bash PHPRC="/etc/php.ini" PHP_FCGI_CHILDREN=4 PHP_FCGI_MAX_REQUESTS=1000 export PHPRC export PHP_FCGI_CHILDREN export PHP_FCGI_MAX_REQUESTS exec /usr/bin/php-cgi
Change permissions of php.fastcgi script to make it executable by Apache server.
chown apache:apache /var/www/cgi-bin/php.fastcgi chmod +x /var/www/cgi-bin/php.fastcgi
Step 6 – Setup VirtualHost with FastCGI
Finally, create a VirtualHost in our Apache configuration file with FastCGI support. VirtualHosts are used to configure multiple sites with a single IP. Below configuration will allow siting svr1.tecadmin.net with any system IP on port 80.
ServerName svr1.tecadmin.net ServerAdmin [email protected] DocumentRoot /var/www/html ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" Options +Indexes +FollowSymLinks +ExecCGI AddHandler php-fastcgi .php Action php-fastcgi /cgi-bin/php.fastcgi AllowOverride All Order allow,deny Allow from All
Step 7 – Restart Apache and Test Setup
At this point, you have completed the Apache configuration with FastCGI support. Let’s restart the Apache server using the following command.
Now create a file in your document root /var/www/html/info.php and add following content to check detailed php information.
Installing and Configuring FastCGI and PHP-FPM on CentOS 8
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
mod_fcgid is an Apache module that uses the FastCGI protocol to provide an interface between Apache and Common Gateway Interface (CGI) programs. CGI helps a web server handle dynamic content generation and processing for scripting languages like PHP. This dynamic functionality is commonly used when running content management systems like WordPress on a LAMP stack.
This guide will show you how to install mod_fcgid and PHP-FPM on CentOS 8. It will also provide a basic configuration that uses socket based connections, instead of TCP. These steps will enable you to run PHP through mod_fcgid . Running PHP through mod_fcgid helps to reduce the amount of system resources used by forcing the web server to act as a proxy and only pass files ending with the .php file extension to PHP-FPM. Additionally, using PHP-FPM allows each virtual host to be configured to run PHP code as individual users.
This guide assumes that you are familiar and comfortable with setting up a LAMP stack on CentOS 8. If you are new to Linux server administration, you may be interested in reading our Linux System Administration Basics guide.
Before You Begin
- Complete the steps in the How to Install a LAMP Stack on CentOS 8 guide. After completing the LAMP stack guide, you should have an Apache virtual hosts configuration for your own website. This guide will continue to refer to the site as example.com .
This guide’s examples will use PHP version 7.2. By default, PHP 7.2 is available for installation from the default CentOS 8 repositories. When running commands related to PHP, ensure you replace any version numbers with your own system’s PHP version.
Install mod_fcgid and PHP-FPM
In this section, you will install the mod_fcgid and PHP-FPM modules on your CentOS 8 Linode.
- Update your system if you have not already done so and install the wget command line utility.
sudo yum update && sudo yum install wget -y
sudo yum install mod_fcgid php-fpm
sudo systemctl restart httpd
Configure Apache with PHP-FPM
You will now configure Apache to pass all requests for files with the .php extension, to the PHP wrapper through FastCGI.
- Configure PHP-FPM to use UNIX sockets instead of TCP. In this command, you will use grep to determine if the sockets are already being used. This command will search your php-fpm installation’s default pool configuration file for the setting.
sudo grep -E '^\s*listen\s*=\s*[a-zA-Z/]+' /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/www.sock