Home >Backend Development >PHP Problem >How to install php module on centos6

How to install php module on centos6

王林
王林Original
2021-09-02 16:45:422268browse

How to install the php module in centos6: 1. Prepare the environment and install dependent packages; 2. Compile and install, add environment variables; 3. Configure Apache to support PHP.

How to install php module on centos6

The operating environment of this article: centos 6 system, php 5.6, thinkpad t480 computer.

The following are the steps for compiling and installing php 5.6 (apache module) on centos6.5:

1. Environment preparation

1. Download the php source code package

# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
# tar -xf php-5.6.30.tar.gz -C /usr/local/src/

2. Create www user

# groupadd www
# useradd -g www -s /sbin/nologin -M www

3. Install epel source

# yum install epel-release -y

4. Install dependent packages

# yum install gcc gcc-c++ make zlib zlib-devel libxml2 libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv libiconv-devel freetype-devel libpng-devel gd bison bison-devel readline-devel gd-devel libicu-devel libedit-devel libcurl-devel sqlite-devel jemalloc jemalloc-devel libxslt-devel libmcrypt libmcrypt-devel mhash mhash-devel mcrypt pcre pcre-devel bzip2 bzip2-devel curl curl-devel openssl-devel openldap openldap-devel -y

2. Compile and install

./configure --prefix=/usr/local/php \
--with-config-file-path=/etc/php/ \
--with-apxs2=/usr/local/httpd24/bin/apxs \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-curl \
--with-zlib \
--with-bz2 \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-xsl \
--with-pcre-dir \
--with-readline \
--with-gettext \
--with-xmlrpc \
--with-libxml-dir \
--enable-shared \
--enable-bcmath \
--enable-soap \
--enable-mbregex \
--enable-pcntl \
--enable-opcache \
--enable-calendar \
--enable-shmop \
--enable-xml \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--enable-ftp \
--enable-zip \
--enable-gd-jis-conv \
--enable-exif \
--enable-mbstring \
--enable-inline-optimization \
--disable-debug \
--disable-rpath
# make && make install

3 , Configure service

# mkdir /etc/php
# cp php.ini-development /etc/php/php.ini

Add environment variable PATH

# vim /etc/profile
PATH=$PATH:/usr/local/php/bin    
export PATH  
# source /etc/profile

View php configuration file path

# /usr/local/php/bin/php --ini

View php compilation parameters

# /usr/local/php/bin/php-config

4. Configure apache to support php

Modify Apache's configuration file httpd.conf
DirectoryIndex index.html index.php #Add index.php
Find:
AddType application/x-compress .Z
AddType application /x-gzip .gz .tgz
Add the following content
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
Check LoadModule php5_module modules/ Whether libphp5.so has been added and whether the libphp5.so file exists
Write the test file index.php with the following content and place it in Apache's default Web site directory DocumentRoot #Default path/var/www/html

<?php
phpinfo();
?>

Start the Apache service. If the startup fails, check the configuration file httpd.conf, find the error log error.log, and modify it according to the problem.

service httpd restart

Use a browser to visit http://IP/, if you can see the PHP configuration, it means you are successful

Recommended learning: php training

The above is the detailed content of How to install php module on centos6. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn