CentOS7 Source Installation PHP7

Source: Internet
Author: User

Objective:

In fact, for many PHP programmers, Linux may still be in a state of little understanding. For example, setting up an environment is more than willing to use the inherited development environment. For the source code compiled installation is unfamiliar. Of course I am no exception. But I think a programmer no matter what language you use to develop. Linux is a thing that doesn't work. So today, learn how to use source code to install P HP7

1. Prerequisites

First of all I used CentOS7 operating system, but also a more mainstream system. Other distributions and even Macs should have a similar approach.
We need to go to the official website to download a source package before we install PHP.

    • In the top left corner, click Downloads
    • Select the PHP version (the latest version I chose here)
    • Select a download source, right-click Copy link (my server in the United States, I chose the United States you can decide by themselves)

The next step is to go to the server.

First of all to download a package, my more commonly used command is wget, if you did not install wget words

Yum Install wget

    • CD to the directory you want to download, use the wget command to download

#把刚刚复制的链接粘贴到命令后面
wget Http://cn2.php.net/get/php-7.2.6.tar.bz2/from/this/mirror

    • This file will be available when the download is complete.

    • Unzip the Mirror file

      TAR-XF Mirror

    • Unzip it as if there will be a PHP folder, this is our PHP installation package
    • Then we CD into the bag. Use the build tool inside it Configura

This configure is actually a shell script to edit our installation package, compile can choose a lot of configuration, such as install some extensions, exclude some extensions, set the path and so on

#可以使用help来查看可以有那些配置
./configure--help

Start Installation Installation dependent

First I found that PHP needs to have two dependencies, the first is GCC (many server images have)
The second one is LIBXML2.
The installation method is very simple

#gcc
Yum Install GCC
#libxml2
Yum Install Libxml2-devel

Compiling PHP

Or are we talking about using./configrue to compile, but we can do some configuration. (Of course not configured also can)

#--prefix=/back to the place you want to install, that is, window to install the software when asked your installation directory
./configure--prefix=/service/php

If your server is like me a garbage, memory super Small then I recommend you add--disable-fileinfo in the back

./configure--prefix=/service/php/--disable-fileinfo

And then just wait (until the advent of Thank you to using PHP)

So after we compile, it is installed, the installation is divided into two parts

#第一步
Make
#第二部
Make install

can also be merged, Make&&make install

It's a long wait (who calls me a bad server)

Verifying the installation

If the installation is not an error, then it should be OK let's check it out.

First, CD to the directory you just set up.
Mine is in/service/php.

The bin directory is a directory of executable files, we enter

CD bin

We want to verify that PHP is installed successfully, we create a PHP file directly to see if we can execute it.

#创建一个php文件
Vim index.php

Enter after writing a little code and save

<?php
echo ' Hello World ';

Then we use PHP to execute the index.php file.

As we can see, the output of Hello World proves that our installation of PHP is successful!

All right, here we go today. I will write more articles about Linux, and also a path of my own learning. If there is a wrong place, welcome to the great God, thank you.

CentOS7 Source Installation PHP7

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.