静态/动态编译在Apache+Php+Mysql的应用
大家有不少都成功实现apache+php+mysql,网上的文章也有不少,但我发现不少文章都是抄来抄去,并且没有说明白编译的方式,有的索性apache1.3的编译方法原封不动的搬过来套在apache2.0,显然误导一些菜鸟!
今天就以apache+mysql+php说一下静态编译和DSO动态编译的区别,我会分别拿apache1.3.27和apache2.0.46
说明,因为两个版本的编译命令是有所区别的。
系统和所需软件:
Redhat9.0
apache:1.3.27 和 2.0.46
php: 4.3.2
mysql:4.0.13
首先来安装mysql,这不是我们的重点,所以关于mysql的安装配置我就很快过去了
tar zvxf mysql-4.0.13.tar.gz
cd mysql-4.0.13
./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql &&
make &&
make install
安装完成!
然后初始化数据库
/usr/local/mysql/bin/mysql_install_db
设置权限:
chown -R root /usr/local/mysql
复制配置文件;
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
启动mysql:
/use/local/mysql/bin/mysqld_safe --user=root &
修改密码:初始的root密码是空的
/usr/local/mysql/bin/mysqladmin -u root -p password 1234
enter password:
把密码修改为1234,由于初始密码为空,所以enter password直接回车就行
测试一下新的密码:
mysql -u root -p mysql
enter password:1234
如果顺利的话就能进入mysql。
好了mysql就讲这么多,有什么问题也不要问我,我对mysql不是很熟悉。好了下面是我们的重头戏,我将分别
通过静态和动态DSO编译apache+php
至于什么是静态,什么是DSO动态我这里就不多讲了,本人个人倾向大家用DSO动态编译。
首先是apache1.3.29+php4.3.4+mysql4.0.13的静态编译
apache第一次编译,并不要安装,因为php的编译需要apache至少已经编译过一次
tar zvxf apache_1.3.27.tar.gz
cd apache_1.3.27
./configure --prefix=/usr/local/apache
#编译php
tar zvxf php4.3.4.tar.gz
cd php4.3.4
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.27 &&
make &&
make install
#第二次编译安装apache:
cd ../apache_1.3.29
./configure --prefi=/usr/local/apache --activate-module=src/modules/php4/libphp4.a &&
make &&
make install
cp ../php4.3.4/php.ini.dist /usr/local/php/lib/php.ini
#修改/usr/local/apache/conf/httpd.conf
查找,在此范围添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
注意:apache和php的源码包在同一个目录,--with-apache=../apache_1.3.27是指向源码解压的目录
#ok!静态编译完成,大家只要启动一下服务器
/usr/local/apache/bin/apachectl start
然后些个php测试页info.php:内容如下
phpinfo();
?>
正常的话,应该能看到php的信息了,恭喜你静态编译成功!!!
我们再来讲讲DSO动态编译的方法:
首先编译安装apache
tar zvxf apache_1.3.29
cd apache_1.3.29
./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite --enable-shared=max &&
make &&
make install
so模块用来提供DSO支持的apachehe核心模块,rewrite是地址重写的模块,如果不需要可以不编译
enable-shared=max是指除了so以外的所有标准模块都编译成DSO模块。
然后编译php
tar zvxf php4.3.4.tar.gz
cd php4.3.2
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs=/usr/local/apache/bin/apxs &&
make &&
make install
然后修改httpd.conf,方法同静态编译的方法
OK,DSO动态编译就完成了,大家应该看出明堂来了吧,中间有什么区别应该看的很清楚了吧!!!
接下来我们讲apache2.0.46+php4.3.2的编译方法,我这里只讲DSO动态编译,静态编译实在没有时间测试了,留给大家自己去试了。
一样现编译安装apache
tar zvxf httpd-2.0.46.tar.gz
cd httpd-2.0.46
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most &&
make &&
make install
大家注意了--enable-so相当与1.3.27的--enable-module=so,而--enable-mods-shared=most又等同与以前的
--enable-shared=max 这些区别大家要注意了,否则编译错了不要找我
然后还是编译PHP
tar zvxf php4.3.2.tar.gz
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs &&
make &&
make install
注意这里是apxs2!!!
修改httpd.conf与1.3.27也有所不同,大家寻找Add Type application/x-tar .tgz 在下面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
另外要显示中文的话,修改:
AddDefaultCharset gb2312
启动一下apache
/usr/local/apache2/bin/apachectl start
用那个info.php测试一下,应该不会有多大问题哦!!!
好了写了这么多,希望对大家有所帮助!!!
【相关文章】

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



When creating a virtual machine, you will be asked to select a disk type, you can select fixed disk or dynamic disk. What if you choose fixed disks and later realize you need dynamic disks, or vice versa? Good! You can convert one to the other. In this post, we will see how to convert VirtualBox fixed disk to dynamic disk and vice versa. A dynamic disk is a virtual hard disk that initially has a small size and grows in size as you store data in the virtual machine. Dynamic disks are very efficient at saving storage space because they only take up as much host storage space as needed. However, as disk capacity expands, your computer's performance may be slightly affected. Fixed disks and dynamic disks are commonly used in virtual machines

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

Deleted something important from your home screen and trying to get it back? You can put app icons back on the screen in a variety of ways. We have discussed all the methods you can follow and put the app icon back on the home screen. How to Undo Remove from Home Screen in iPhone As we mentioned before, there are several ways to restore this change on iPhone. Method 1 – Replace App Icon in App Library You can place an app icon on your home screen directly from the App Library. Step 1 – Swipe sideways to find all apps in the app library. Step 2 – Find the app icon you deleted earlier. Step 3 – Simply drag the app icon from the main library to the correct location on the home screen. This is the application diagram

The role and practical application of arrow symbols in PHP In PHP, the arrow symbol (->) is usually used to access the properties and methods of objects. Objects are one of the basic concepts of object-oriented programming (OOP) in PHP. In actual development, arrow symbols play an important role in operating objects. This article will introduce the role and practical application of arrow symbols, and provide specific code examples to help readers better understand. 1. The role of the arrow symbol to access the properties of an object. The arrow symbol can be used to access the properties of an object. When we instantiate a pair

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

The Linuxtee command is a very useful command line tool that can write output to a file or send output to another command without affecting existing output. In this article, we will explore in depth the various application scenarios of the Linuxtee command, from entry to proficiency. 1. Basic usage First, let’s take a look at the basic usage of the tee command. The syntax of tee command is as follows: tee[OPTION]...[FILE]...This command will read data from standard input and save the data to

The Go language is an open source programming language developed by Google and first released in 2007. It is designed to be a simple, easy-to-learn, efficient, and highly concurrency language, and is favored by more and more developers. This article will explore the advantages of Go language, introduce some application scenarios suitable for Go language, and give specific code examples. Advantages: Strong concurrency: Go language has built-in support for lightweight threads-goroutine, which can easily implement concurrent programming. Goroutin can be started by using the go keyword
