Home > Article > Backend Development > Application of static/dynamic compilation in Apache+Php+Mysql_PHP tutorial
Many people have successfully implemented apache+php+mysql, and there are many articles on the Internet, but I found that many articles are copied over and over again, and do not explain the compilation method, and some simply The compilation method of apache1.3 has been transferred intact to apache2.0, which obviously misleads some novices!
Today I will talk about the difference between static compilation and DSO dynamic compilation using apache+mysql+php. I will use apache1.3.27 and apache2.0.46 respectively
to explain, because the two versions of compilation The commands are different.
System and required software:
Redhat9.0
apache:1.3.27 and 2.0.46
php: 4.3.2
mysql: 4.0 .13
First of all, let’s install mysql. This is not our focus, so I will quickly go over the installation and configuration of 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
Installation completed!
Then initialize the database
/usr/local/mysql/bin/mysql_install_db
Set permissions:
chown -R root /usr/local/mysql
Copy 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. Since the initial password is empty, just enter password and press Enter
Test the new password:
mysql -u root -p mysql
enter password :1234
If everything goes well, you can enter mysql.
Okay, that’s all about mysql. If you have any questions, don’t ask me. I’m not very familiar with mysql. Okay, here is our highlight, I will compile apache+php through static and dynamic DSO respectively
As for what is static and what is dynamic DSO, I will tell you here Not much to say, I personally prefer everyone to use DSO dynamic compilation.
The first is the static compilation of apache1.3.29+php4.3.4+mysql4.0.13
The first time compilation of apache, do not install , because the compilation of php requires apache It has been compiled at least once
tar zvxf apache_1.3.27.tar.gz
cd apache_1.3.27
./configure --prefix=/usr/local/apache
#Compile 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
#Compile and install apache for the second time:
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 scope
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 points to the directory where the source code is decompressed
#ok! The static compilation is completed, you just need to start the server
/usr/local/apache/bin/apachectl start
Then some php test pages info.php: the content is as follows
phpinfo();
?>
If it is normal, you should be able to see the php information. Congratulations on the successful static compilation! ! !
Let’s talk about the method of DSO dynamic compilation:
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 core module of apachehe that supports DSO. Rewrite is an address rewriting module. You don’t need to compile it if you don’t need it.
enable-shared=max means that all standard modules except so are compiled into DSO module.
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, the method is the same as the static compilation method
OK, DSO dynamic compilation is completed. You should see that Mingtang is coming, and you should be able to see the difference clearly! ! !
Next we will talk about the compilation method of apache2.0.46+php4.3.2. I will only talk about DSO dynamic compilation here. I really don’t have time to test static compilation, so I leave it to you to try it yourself.
Compile and install apache as usual
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
Please note that --enable-so is quite similar to 1.3.27's --enable-module=so, and --enable-mods-shared=most are equivalent to the previous
--enable-shared=max. You should pay attention to these differences, otherwise don't look for errors in compilation. I
and 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! ! !
Modifying httpd.conf is also different from 1.3.27. Look for Add Type application/x-tar .tgz and add it below
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
If you want to display Chinese, modify:
AddDefaultCharset gb2312
Start apache
/usr/local/apache2/bin/apachectl start
Test it with the info.php, there shouldn’t be much problem! ! !
Okay, I have written so much, I hope it will be helpful to everyone! ! !
【Related articles】