Php5.6+apache2.4+linux build PHP environment, php5.6apache2.4_php tutorial

Source: Internet
Author: User

Php5.6+apache2.4+linux build PHP environment, php5.6apache2.4


Objective

Recently suddenly want to build a personal blog, although I am good at java-web, but a combination of various reasons, so chose the popular Php+mysql build personal blog. For PHP, only to hear its name, but never learned, so, I will start from the PHP environment, to the server, the lease of the domain name, PHP blog template selection, a record of the entire process. It takes one months for the final process to take one months to learn PHP, to rent a server and find a blog template. Now let's start by building a PHP environment . Note that this is a tutorial on a Linux server that has successfully installed the centos6.4 test on a virtual machine, as for Windows, the author card is loaded into the module section, alas ....

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

  install Apache (2.4) Server :

Before Apache installs, you need to install APR, Apr-util, and pcre dependent packages, because Apache is dependent 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

The download address for Apache 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 the download is installed (related directories need to build their own)

  installation of 1.APR :

  Extract: Execute under Apr file path (download file has MV to Apr directory)

TAR-ZXVF apr-1.5.1.tar.gz, the file is extracted 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 for setup directory, and configure front with spaces , note)

(4) Make

(5) Make install

installation of 2.apr-util:

Unzip: Execute under Apr-util file path (download file has MV to apr-util directory)

TAR-ZXVF apr-util-1.5.4.tar.gz, the file is extracted 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 installation directory)

(4) Make

(5) Make install

installation of 3.pcre:

Unzip: Execute under Pcre file path (download file has MV to pcre directory)

TAR-ZXVF pcre-8.36.tar.gz, the file is extracted 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 installation directory)

(4) Make

(5) Make install

  

  4. The final step is to install Apache:

Unzip: Execute under Apache file path (download file has MV to Apache directory)

TAR-ZXVF httpd-2.4.10.tar.gz, the file is extracted 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 to APR installation path, same as below)

--with-apr-util=/usr/local/apr-util

--with-pcre=/usr/local/pcre

Installation parameters specific meaning please help

(4) Make

(5) Make install

At this point, Apache is already installed, and the next step is to start and test whether it started successfully.

Execute command:

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

Check if there is an Apache process

PS aux | grep httpd

as follows, the result of the author's execution of the command

  

If there is a process, you can enter http://localhost, the result of the author is

  

Because it is deployed on a virtual machine, it is used by the IP access of the virtual machine.

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

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

Service httpd Start

You can start the service directly.

  Install PHP

Before you install PHP, you need to make sure that LIBXML2 is installed and that the download address is:

http://download.chinaunix.net/download.php?id=28497&ResourceID=6095

At that time, I was also casual Baidu, not the official, if the need for official words, please make your own search ability to play

The installation is basically the same as above, just a simple list of commands.

(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 put the LIBXML2 installed.

The next step is to install PHP.

The official download address is:

http://php.net/downloads.php

Then it was installed.

After copying the files to/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 where PHP needs to be installed)

--with-mysql=/usr/local/mysql (path is the installation path of the installed MySQL)

--with-apxs2=/usr/local/apache2.4/bin/apxs (in some tutorials is written--with-apxs, here is apxs2,2 is version 2 above the set)

--WITH-LIBXML2=/USR/LOCAL/LIBXML2 (That's the path we installed libxm2 above)

And then Make,make install it.

  

The final thing is to configure Apache to support PHP

Modify the Apache configuration file httpd.conf

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

Then add the last face of the text

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

  addtype application/x-httpd-php. PHP (. Preceded by a space)

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

Author configuration

  

Next, copy the PHP boot file

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

Save, restart

Service httpd Start

If there is no error, the boot is successful.

  

  Test if PHP is installed successfully

Write a simple PHP page, as follows

  

is not very simple, and then saved as welcome.php, 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

  

  

  Summarize:

When you build PHP environment, you should refer to a few tutorials. Each tutorial version and other factors may be different, so it is not necessarily suitable for everyone, this is also the author's experience, referring to a lot of tutorials. The reason to write this tutorial is to find a lot of 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

  

http://www.bkjia.com/PHPjc/913103.html www.bkjia.com true http://www.bkjia.com/PHPjc/913103.html techarticle php5.6+apache2.4+linux Build PHP environment, php5.6apache2.4 preface recently suddenly want to build a personal blog, although the author is good at Java-web, but a combination of various reasons, so chose the popularity of P ...

  • Related Article

    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.