Compiling and installing PHP under Linux environment

Source: Internet
Author: User
Tags install php

Following the previous article MySQL, this chapter is about how to deploy PHP services.

Third, PHP installation 1. First install the GD library and the GD Library Association program (used to process and generate pictures).

Yum install \
Libjpeg-devel \
Libpng-devel \
Freetype-devel \
Zlib-devel \
Gettext-devel \
Libxpm-devel \
Libxml2-devel \
Fontconfig-devel \
Openssl-devel \
Bzip2-devel

2. Unzip and install the GD library to/OPT
   tar xzvf gd-2.0.35.tar.gz -C /opt
3. Configure, compile, and install GD

#进入gd目录下
cd/opt/gd/2.0.35
Configuration
./configure--PREFIX=/USR/LOCAL/GD
Compiling and installing
Make && make install

4. Install the PHP package into the OPT directory
  tar xjvf /opt/lamp/php-5.4.5.tar.bz2 -C /opt
5. Configure, compile, and install PHP

Go to the PHP directory first
cd/opt/php-5.4.5/
Then configure
./configure \
--prefix=/usr/local/php \
--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS \
--WITH-GD \
--with-mysql=/usr/local/mysql \
--WITH-CONFIG-FILE-PATH=/ETC \
--enable-sqlite-utf8 \
--with-zlib-dir \
--with-libxml-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--WITH-TTF \
--with-iconv \
--WITH-OPENSSL \
--with-gettext \
--enable-mbstring \
--ENABLE-GD-NATIVE-TTF \
--enable-gd-jis-conv \
--enable-static \
--enable-zend-multibyte \
--enable-inline-optimization \
--enable-sockets \
--ENABLE-SOAP \
--ENABLE-FTP \
--disable-ipv6
Compiling and installing
Make && make install

6. Optimizing PHP Paths
 cp php.ini-production /etc/php.ini
7. Configure Apache to support PHP
   vim /usr/local/apache/conf/httpd.conf

Find AddType application/x-gzip gz. tgz below to add the following:
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps
LoadModule php5_module modules/libphp5.so//Check for presence
DirectoryIndex index.php index.html//Adjust home file settings

8. Restart the HTTPD service

Service httpd Stop
Service httpd Start

9. Create a PHP test page

Go to the Apache directory to write index.html
Enter the following content
<?php
Phpinfo ();
?>
Change index.html to PHP format specifically as

Test

View the contents of the PHP test page, such as

Compiling and installing PHP under Linux environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.