Static/dynamic compilation in Apache + Php + Mysql _ PHP Tutorial

Source: Internet
Author: User
Static dynamic compilation in Apache + Php + Mysql applications. Many of you have successfully implemented apache + php + mysql and many articles on the Internet, but I have found that many articles are copied and did not describe the white compilation method, in some cases, many apach users have successfully implemented apache + php + mysql and many articles on the Internet, but I found that many articles are copied and copied, in addition, there is no explanation of the white compilation method. some simple compilation methods of apache1.3 are moved from apache2.0, which clearly misleads some Cainiao!

Today, we will talk about the differences between static compilation and dynamic DSO compilation using apache + mysql + php. I will take apache1.3.27 and apache2.0.46 respectively.

Note: the compilation commands of the two versions are different.

Systems and required software:
Redhat9.0
Apache: 1.3.27 and 2.0.46
Php: 4.3.2
Mysql: 4.0.13

First install mysql, This is not our focus, so I will soon pass the mysql installation configuration

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

Installation complete!

Then initialize the database

/Usr/local/mysql/bin/mysql_install_db

Set permissions:

Chown-R root/usr/local/mysql

Copy the configuration file;

Cp/usr/local/mysql/share/mysql/my-medium.cnf/etc/my. cnf

Start mysql:

/Use/local/mysql/bin/mysqld_safe -- user = root &

Change Password: the initial root password is empty.

/Usr/local/mysql/bin/mysqladmin-u root-p password 1234
Enter password:

Change the password to 1234. because the initial password is empty, enter password and press enter.

Test the new password:

Mysql-u root-p mysql
Enter password: 1234

If it succeeds, you can access mysql.

I am not very familiar with mysql. Well, the following are our highlights.

Compile apache + php through static and dynamic DSO

As for what is static and what is DSO dynamics, I will not talk about it here. I personally prefer to use DSO for dynamic compilation.

First, the static compilation of apache1.3.29 + php4.3.4 + mysql4.0.13

Do not install apache for the first time.Because php compilation requires apache to be compiled at least once.

Tar zvxf apache_1.3.27.tar.gz
Cd apache_1.3.27
./Configure -- prefix =/usr/local/apache

# Compiling 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

# The second compilation and installation of 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

# Modify/usr/local/apache/conf/httpd. conf

Search, add in this range

AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps

Note: the source code packages of apache and php are in the same directory. -- with-apache = ../apache_1.3.27 indicates the directory to which the source code is extracted.

# OK! Static Compilation is complete. you only need to start the server.

/Usr/local/apache/bin/apachectl start

Then, enter the php test page info. php: the content is as follows:

Phpinfo ();
?>

Normally, you should be able to see the php information. congratulations, the static compilation is successful !!!

Let's talk about the DSO dynamic compilation method:

First, compile and install 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

The so module is used to provide the apachehe core module supported by DSO. the rewrite module is the address rewriting module and can be compiled without any need.
Enable-shared = max indicates that all standard modules except so are compiled into DSO modules.

Then compile 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

Then modify httpd. conf in the same way as static compilation.

OK. DSO dynamic compilation is complete. you can see the differences between them !!!

Next, let's talk about the compilation method of apache2.0.46 + php4.3.2. here I only talk about DSO dynamic compilation. static compilation does not have time to test, so I will leave it to everyone to try it.

Compile and install apache

Tar zvxf httpd-2.0.46.tar.gz
Cd httpd-2.0.46
./Configure -- prefix =/usr/local/apache2 -- enable-so -- enable-MoD-shared = most &&
Make &&
Make install

You have noticed that -- enable-so is equivalent to -- enable-module = so of 1.3.27, while -- enable-MoD-shared = most is equivalent to the previous
-- Enable-shared = max these differences should be noted, otherwise the compilation is wrong, do not contact me

Then compile 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

Note that this is apxs2!!!

The modification of httpd. conf is different from that of 1.3.27. you can find Add Type application/x-tar. tgz and Add

AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps

To display Chinese characters, modify:

Adddefacharcharset gb2312

Start apache

/Usr/local/apache2/bin/apachectl start

Test it with info. php. it should not be a big problem !!!

Well, I have written so much, I hope it will help you !!!

[Related articles]


...

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.