Apache2.4x supports PHP access, solving the problem of garbled code when accessing PHP downloads!

How does Apache2.4x support PHP access? The default installation of Apache2.4x does not support PHP access. You need to modify it step by step to access PHP files.
The first step is to confirm whether you have added it when installing PHP.Interactive parameters. --with-apxs2=/usr/local/apache2/bin/apxs
There are basically no problems with yum installation. Here we will talk about what will happen if you install PHP manually.
Open phpinfo and check if there are any interactive parameters for Apache.
Apache2.4x supports PHP access, solving the problem of garbled code when accessing PHP downloads!
You can see that on this probe page, there is no parameter --with-apxs2=/usr/local/apache2/bin/apxs.
You need to reinstall and compile php7.4.3
Enter the installation file directory of php7.4.3 and enter the command:

Mack Clech

Clear all the contents of the files generated by configure. Re-configure and install.

./configure \ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --disable-fileinfo \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-xmlrpc \ --with-openssl \ --with-mhash \ --with-sqlite3 \ --with-zlib \ --enable-gd \ --with-jpeg \ --with-freetype \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-filter \ --enable-ftp \ --with-openssl-dir \ --enable-gd-jis-conv \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --with-xsl \ --enable-mysqlnd-compression-support \ --with-pear \ --with-apxs2=/usr/local/apache2/bin/apxs \ --enable-opcache \

After the configuration is checked, compile and install. After the installation is complete, restart the server.

make make install reboot

Apache2.4x supports PHP access, solving the problem of garbled code when accessing PHP downloads!
After starting, check phpinfo again and you will find that the interactive parameters of Apache have been installed. Why is it called interactive? After PHP supports APACHE, APACHE must also support PHP. Next, modify the relevant configuration files of Apache2.4x.

vi /usr/local/apache2/conf/httpd.conf

First check whether the PHP module is loaded successfully. LoadModule php7_module modules/libphp7.so
In VI mode, enter:/command to search.

:/libphp7.so

The libphp7.so module has been successfully loaded, continue to the next step.
Add .PHP file parsing under the container

AddType application/x-httpd-php .php AddType application/x-httpd-php-source .php7

Copy and paste the above content into . You can add it under "AddType application/x-gzip .gz .tgz".
By the way, add at the end of the file

AddDefaultCharset UTF-8

Apache's language support.
Exit VI editing mode, save the file with :wq, and restart the httpd server.

systemctl reload httpd

PHP access has taken effect. If the browser page still prompts to download or cannot be browsed, clear the browser cache and reopen it.

1/5 - (2 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *