Linux builds the latest version of the PHP server environment (php5.6+apache2.4)

Source: Internet
Author: User
Tags install php php server

Building PHP environment is mainly divided into three steps, the first step is

install Apache (2.4) Server:

Before Apache is installed, you need to install the APR, Apr-util, and pcre dependencies, because Apache relies on them. The specific download address is as follows

Apr and apr-util:http://apr.apache.org/download.cgi
Pcre:http://sourceforge.net/projects/pcre/files/pcre

Apache's official download address is: http://httpd.apache.org/download.cgi

The author downloads the version specifically, Apache (httpd-2.4.10.tar.gz), Apr (apr-1.5.1.tar.gz), Apr-util (apr-util-1.5.4.tar.gz), Pcre ( pcre-8.36.tar.gz).

After downloading is installed (related directories need to build their own)

1.APR Installation:

Decompression: Under the Apr file path Execution (download file has MV to the APR directory)
TAR-ZXVF apr-1.5.1.tar.gz, the file is uncompressed to the current path.
To create a soft link and install:
(1) Ln-s/OPT/APR/APR/USR/LOCAL/APR
(2) CD apr-1.5.1
(3)./configure--prefix=/usr/local/apr (prefix to set up the installation directory, and configure preceded by a space, note)
(4) Make
(5) Make install

installation of 2.apr-util:

Decompression: Execute under Apr-util file path (download file already mv to Apr-util directory)
TAR-ZXVF apr-util-1.5.4.tar.gz, the file is uncompressed to the current path.
To create a soft link and install:
(1) Ln-s/opt/apr/apr-util/usr/local/apr-util
(2) CD apr-util-1.5.4
(3)./configure--prefix=/usr/local/apr-util (prefix for setup directory)
(4) Make
(5) Make install

3.pcre Installation:

Decompression: Execute under Pcre file path (download file already mv to pcre directory)
TAR-ZXVF pcre-8.36.tar.gz, the file is uncompressed to the current path.
To create a soft link and install:
(1) Ln-s/opt/apr/pcre/usr/local/pcre
(2) CD pcre-8.3.6
(3)./configure--prefix=/usr/local/pcre (prefix for setup directory)
(4) Make
(5) Make install

4. The final step is to install Apache:

Decompression: Execute in Apache file path (download file has MV to Apache directory)
TAR-ZXVF httpd-2.4.10.tar.gz, the file is uncompressed to the current path.
To create a soft link and install:
(1) Ln-s/opt/apr/apache/usr/local/apache
(2) CD httpd-2.4.10
(3)./configure--prefix=/usr/local/apache2.4
--enable-so-rewrite=shared
--with-mpm=prefork
--WITH-APR=/USR/LOCAL/APR (path for APR installation path, hereinafter)
--with-apr-util=/usr/local/apr-util
--with-pcre=/usr/local/pcre
Installation parameters specific meaning please help
(4) Make
(5) Make install

Now that Apache has been installed, the next step is to start and test whether it started successfully.

To execute a command:

/usr/local/apache2.4/bin/apachectl start

Check to see if there is an Apache process

PS aux | grep httpd

As follows, is the author of the results of the implementation of the command



If there is a process, you can enter http://localhost

If you can see "It works!", it does work!

For later convenience, you can add it to the service, copy the Apachectl to the/ETC/INIT.D/HTTPD, and execute

Service httpd Start

You can start the service directly.


Installing PHP

Before installing PHP you need to ensure that LIBXML2 is installed, download the address: http://download.chinaunix.net/download.php?id=28497&ResourceID=6095

I was also casually Baidu, not the official, if the need for official words, please play their own search ability

The installation is basically the same as the above, simply list the order

(1) TAR-ZXVF libxml2-2.7.4.tar.gz
(2) CD libxml2-2.7.4
(3)./configure--PREFIX=/USR/LOCAL/LIBXML2
(4) Make
(5) Make install

This will set up the LIBXML2.

The next step is to install PHP

The official download address is: http://php.net/downloads.php

Then it installs the

After the file is copied to the/opt/php
Extract:
TAR-ZXVF php-5.6.3.tar.gz
And then:
CD php-5.6.3
To perform the installation:
./configure
--prefix=/usr/local/php (path is the path required to install PHP)
--with-mysql=/usr/local/mysql (path for installed MySQL installation path)
--with-apxs2=/usr/local/apache2.4/bin/apxs (in some tutorials is written in--with-apxs, here is written apxs2,2 is version 2 above the set)
--WITH-LIBXML2=/USR/LOCAL/LIBXML2 (the path that we installed libxm2 above)

And then Make,make install on it.

The last thing is to configure Apache to support PHP.

Modify Apache configuration file httpd.conf

Vim/usr/local/apache2.4/conf/httpd.conf

And then add it at the end of the text

LoadModule Php5_module modules/libphp5.so

(Note that in the Apache installation directory, modules under the libphp5.so, which is added to the PHP installation, if not, PHP, you need to reload)

AddType application/x-httpd-php. php

(. Preceded by a space)

(Note that if the above is not configured properly, the Access http:localhost/*.php will be downloaded directly, not opened)

The author Configuration screenshot



Next Copy the PHP startup file

CP Php-5.6.3/php.ini-development/usr/local/php/lib/php.ini

Save, reboot

Service httpd Start

If there is no error, the start is successful



test whether PHP is installed successfully

Write a simple PHP page

<?php
Phpinfo ();
?>

Then save it as welcome.php, and the file needs to be placed in the Apache Htdocs directory

Enter http://localhost/welcome.php in the browser

If you see the following page, the installation is successful



Summary: When you build a PHP environment, refer to several tutorials. Each tutorial version and other factors may be different, so it is not necessarily suitable for everyone, this is the author's experience, reference to a lot of tutorials. The reason to write this tutorial is that many of the tutorials are not comprehensive, so I hope that the author's experience, to be learning PHP coder some help. In the installation process encountered difficulties in children's shoes can give me a message, I will try to help everyone

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.