linux+apache2.4+php5.6 Environment Construction

Source: Internet
Author: User

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. Specific as follows


Apr and apr-util:http://apr.apache.org/download.cgi

Pcre:http://sourceforge.net/projects/pcre/files/pcre


The official 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


If a newline executes an error, it is executed in a non-wrapped manner:


./configure--prefix=/usr/local/apache2.4--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util-- With-pcre=/usr/local/pcre

Make

Make install



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-ef|grep httpd







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/ETC/INIT.D/HTTPD, and execute


Service httpd Start


You can start the service directly.



Install PHP


Before you install PHP, you need to ensure that you have installed LIBXML2: http://download.chinaunix.net/download.php


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: 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)


LoadModule Php5_module modules/libphp5.so


AddType application/x-httpd-php. php



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


<?php

Phpinfo ();

?>


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


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


If you see the following page, the installation is successful


This article is from the "Knife" blog, please be sure to keep this source http://quyong.blog.51cto.com/2434342/1860289

linux+apache2.4+php5.6 Environment Construction

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.