How to install php module on centos6

王林
Release: 2023-03-12 10:22:01
Original
2227 people have browsed it

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/
Copy after login

2. Create www user

# groupadd www
# useradd -g www -s /sbin/nologin -M www
Copy after login

3. Install epel source

# yum install epel-release -y
Copy after login

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
Copy after login

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
Copy after login
# make && make install
Copy after login

3 , Configure service

# mkdir /etc/php
# cp php.ini-development /etc/php/php.ini
Copy after login

Add environment variable PATH

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

View php configuration file path

# /usr/local/php/bin/php --ini
Copy after login

View php compilation parameters

# /usr/local/php/bin/php-config
Copy after login

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();
?>
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template