Home > Backend Development > PHP Problem > How to install apache php under linux

How to install apache php under linux

藏色散人
Release: 2023-03-01 21:00:02
Original
3701 people have browsed it

How to install apache php under linux: first download "httpd-2.2.11" and decompress the installation package; then compile and install through "make install"; then download php and compile and install; finally modify the configuration file That’s it.

How to install apache php under linux

The process of installing apache PHP under linux

Summary of the process of installing apache

Install httpd-2.2.11

Download address: http://archive.apache.org/dist/httpd/

Installation process

[root@zhibing /]# rpm -qa |grep httpd
httpd-manual-2.0.52-32.ent
httpd-suexec-2.0.52-32.ent
system-config-httpd-1.3.1-1
httpd-2.0.52-32.ent                         
                              //查看本机是否已经安装httpd
 
[root@zhibing /]# rpm -e httpd --nodeps        
                             //删除本机存在的httpd
 
[root@zhibing tmp]# tar zxvf httpd-2.2.11.tar.gz  
                            //解压安装包 
 
[root@zhibing tmp]# cd httpd-2.2.11           
                           //进入httpd-2.2.11
 
[root@zhibing httpd-2.2.11]# ./configure --prefix=/usr/local/apache --enable-s0
                          //检测程序, --prefix 软件要安装的路径–enable-so表示让apache核心装载DSO,但是不实际编译任何动态模块
 
[root@zhibing httpd-2.2.11]# make           
                          //编译
 
[root@zhibing httpd-2.2.11]# make install      
                        //编译后安装
Copy after login

Install php-5.2.9

Download address: http://cn.php.net/downloads.php

Note: Before installing php-5.2.9, png, gd, freetype, zlib, mysql, openssl all exist. If they do not exist, install them manually

Installation process

[root@zhibing tmp]# tar  zxvf php-5.2.9.tar.gz  
[root@zhibing tmp]#cd php-5.2.9.tar.gz
[root@zhibing php-5.2.9]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-png-dir --with-gd --with-freetype-dir --with-zlib --with-mysql=/usr/local/mysql --with-openssl --with-gettext -enable-sockets
                           //检测程序,并同时加载相关参数
 
[root@zhibing php-5.2.9]#make && make install    
                              //编译安装
 
 
[root@zhibing php-5.2.9]#cp php.ini-recommended /usr/local/php/lib/php.ini
                         //拷贝php.ini文件启动时会读取到的配置文件
 
[root@zhibing php-5.2.9]#ln -s /usr/local/php/bin/* /usr/local/bin/  
                         //连接
 
ot@zhibing php-5.2.9]#lvi /usr/local/apache/conf/httpd.conf 
                                        //修改配置文件
Copy after login

Add

AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType p_w_picpath/x-icon .ico
Copy after login

Add

index.php index.html index.html.var
  <IfModule dir_module>
    DirectoryIndex index.html index.php index.html index.html.var
</IfModule>
Copy after login

Test:

[root@zhibing ]#vi /usr/local/apache/htdocs/test.php 
//新建test.php
Copy after login

In new file Add

<?php
phpinfo();
?>
Copy after login

wqSave and exit

Phpinfo is a special php function that can display the relevant core data of the php module in the current server

[root@zhibing ]## /usr/local/apache/bin/apachectl –k stop
 
[root@zhibing ]##/usr/local/apache/bin/apachectl –k start
                                 //重新启动apache
Copy after login

Enter the host address in the browser, for example http://hostIP/test.php. If the following picture appears, it means apace is successfully installed.

How to install apache php under linux

The above is the detailed content of How to install apache php under linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template