In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to build a Linux+apache2.4+php5.6 environment, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
There are three main steps to build a php environment. The first step is
Install the apache (2.4) server:
Before you install apache, you need to install APR, APR-Util, and PCRE dependency packages because apache depends 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 official download address of apache is: http://httpd.apache.org/download.cgi
The version downloaded by the author is 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, it will be installed (the relevant directory needs to be built by yourself)
Installation of 1.apr:
Extract: execute under the path of the apr file (the downloaded file has been mv to the apr directory)
Tar-zxvf apr-1.5.1.tar.gz, the file will be extracted to the current path
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 sets the installation directory, and there is a space before configure, note below)
(4) make
(5) make install
Installation of 2.apr-util:
Extract: execute under the path of the apr-util file (the downloaded file has been mv to the apr-util directory)
Tar-zxvf apr-util-1.5.4.tar.gz, the file will be extracted to the current path
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 is the setup installation directory)
(4) make
(5) make install
Installation of 3.pcre:
Extract: execute under the path of the pcre file (the downloaded file has been mv to the pcre directory)
Tar-zxvf pcre-8.36.tar.gz, the file will be extracted to the current path
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 is the setup installation directory)
(4) make
(5) make install
4. The final step is to install apache:
Extract: execute under the path of the apache file (the downloaded file has been mv to the apache directory)
Tar-zxvf httpd-2.4.10.tar.gz, the file will be extracted to the current path
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 is the installation path of apr, same below)
-- with-apr-util=/usr/local/apr-util
-- with-pcre=/usr/local/pcre
If an error is reported by line wrapping, it is executed in a way that does not wrap:
. / 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
For the specific meaning of the installation parameters, please help
(4) make
(5) make install
At this point, apache has been installed, and the next step is to start and test whether it has started successfully.
Execute the 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 future 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 installing php, you need to make sure that libxml2 is installed. The download address is http://download.chinaunix.net/download.php.
At that time, the author was also casual Baidu, not official, if you need official, please give full play to your own search ability.
In fact, the installation is roughly the same as above, just simply list the 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 installs the libxml2.
The next step is to install php
The official download address is: http://php.net/downloads.php
Then it was installed.
After copying the file to / opt/php
Decompress:
Tar-zxvf php-5.6.3.tar.gz
Then:
Cd php-5.6.3
Perform the installation:
. / configure
-- prefix=/usr/local/php (path is the path where php needs to be installed)
-- with-mysql=/usr/local/mysql (the path is the installation path of the installed mysql)
-- with-apxs2=/usr/local/apache2.4/bin/apxs (in some tutorials it says-- with-apxs, here it says that apxs2,2 is above version 2, so set it up)
-- with-libxml2=/usr/local/libxml2 (the path where we installed libxm2 above)
Then make,make install will be fine.
Finally, configure apache to support php
Modify the configuration file httpd.conf of apache
Vim / usr/local/apache2.4/conf/httpd.conf
Then add it at the end of the text
LoadModule php5_module modules/libphp5.so
(note that in the apache installation directory, there is libphp5.so under modules, which is added during php installation. If not, php, you need to reinstall)
AddType application/x-httpd-php .php
(. There is a space in front)
(note that if the above item is not properly configured, accessing http:localhost/*.php will download it instead of opening it.)
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
Next, copy the php startup file
Cp php-5.6.3/php.ini-development / usr/local/php/lib/php.ini
Save, restart
Service httpd start
If no error is reported, the startup is successful.
Test whether php is installed successfully
Write a simple php page
Then save it as welcome.php, and put the file in the htdocs directory of apache.
Enter http://localhost/welcome.php in the browser
If you see the following page, the installation is successful
These are all the contents of the article "how to build a Linux+apache2.4+php5.6 Environment". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.