• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

Compiling PHP from source on CentOS

PHP

PHP is a  open source scripting language, commonly used for web development. The code is executed on the server before being displayed to clients unlike other languages like JavaScript.  PHP can also be used for command line actions as well and has a wide range of libraries and frameworks for it.  This guide is  how to install PHP from source. Compiling packages from source can offer complete control on the build you have installed on your server, it can also allow to control the path its installed on. This also makes it easier to upgrade to newer releases, you would just compile a newer version and install it.

To start ssh to your server

Install dependencies through yum:

yum install -y wget gcc libxml2-devel openssl openssl-devel openssl-libs curl libcurl-devel libjpeg-turbo-devel libpng-devel freetype-devel libmcrypt libmcrypt-devel libxslt libxslt-devel

Obtain the PHP source package:

For this guide we are going to use the 5.6 release branch:

wget -O /usr/src/php-5.6.30.tar.gz http://php.net/get/php-5.6.30.tar.gz/from/this/mirror

Or select another mirror to download it from.

Unzip the compressed package:

cd /usr/src; tar xfvz php-5.6.30.tar.gz

Go into the directory:

cd php-5.6.30

Install the package:

Configure the package:

./configure  --with-mysql --with-mysqli --with-pdo-mysql --enable-soap --with-gd --with-curl --with-jpeg-dir=/opt --with-png-dir=/opt --with-freetype-dir=/opt --with-zlib --enable-mbstring --with-mcrypt=/usr/local/lib --with-xsl --with-openssl  --enable-ftp --enable-exif --with-apxs2=/usr/sbin/apxs

The above configuration line assumes you have Apache installed, if not remove  –with-apxs2=/usr/sbin/apxs. In this example we are just letting php install in the default location, however you can specific where you would like to install.

Install it:

make && make install

Make sure it works:

php -v

The above command should return the version of php you have installed.

Enable PHP in Apache

Add the following line to your apache configuration:

LoadModule php5_module        lib/apache/libphp5.so

Restart apache:

service httpd restart

To edit the default configuration file’s location by typing the following

php -i|grep php.ini

It will return the path and file it is using and you can edit it to add more configuration options.  Check out Zend OpCache to add more performance to your installation.

Apr 22, 2017LinuxAdmin.io
1 1 vote
Article Rating
using inotify-tools to trigger eventsSetup and Optimize Zend OpCache
You Might Also Like
 
Recover A Root Password On CentOS
 
How To Configure A Nginx Reverse Proxy With Apache
Subscribe
Notify of
guest
guest
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Karim
Karim
5 years ago

Right here is the perfect blog for anybody who would like to understand this topic. You know a whole lot its almost hard to argue with you (not that I really will need to…HaHa). You definitely put a new spin on a topic that’s been discussed for ages. Great stuff, just excellent!

0
Reply
Raj
Raj
4 years ago

Not found lib/apache/libphp5.so.

0
Reply
LinuxAdmin.io
Author
LinuxAdmin.io
4 years ago
Reply to  Raj

Hello,
You would either want to comment out the libphp module or compile php5. Thanks!

0
Reply
6 years ago 3 Comments Apache, PHP, Web Hosting linux6,634
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
63,004 views
Zend Opcache
Setup and Optimize Zend OpCache
46,714 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,912 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz