In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to install PHP5.2 and PHP5.3 on a machine at the same time, I believe 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 learn about it!
The Linux used for testing is Fedora 14. The initial state is that Apache 2.0.64 and PHP5.2.6 have been installed, respectively, in the following path:
/ usr/local/apache2
/ usr/local/php5
Now you need to install another set of PHP5.3 and keep the original PHP5.2, ideally they can share the existing Apache 2. Considering that PHP also needs to run on the command line, that is, it does not go through Apache, which involves system environment variables, so prepare yourself from environment variables first.
1. In order to make it easier to switch PHP versions without changing the environment variables, let's make a soft link so that you only need to modify the soft link when switching versions.
# mkdir-p / usr/php/
# ln-s / usr/local/php5 / usr/php/default
Then add the system environment variables
# vi / etc/profiles
Add a line at the beginning of the file
PHP_HOME=/usr/php/default
Then find the PATH= line and add PHP_HOME, such as
PATH=$JAVA_HOME/bin:$PATH:$PHP_HOME/bin:$MYSQL_HOME/bin
Exit the command line window and reopen it for the environment variable to take effect, execute
$php-version
Can output PHP 5.2.6 (cli) and so on, indicating that soft links and environment variables have been set.
two。 The module that backs up the PHP5.2 of apache
Find the libphp5.so file under / usr/local/apache2/modules, which should be the module compiled during the existing PHP5.2 installation, and back it up with a different name, so that we can compile and generate a new PHP module when we install PHP5.3 below.
# mv libphp5.so libphp526.so
3. Compile and install PHP5.3
You can choose the specific configuration. As long as you note that the installation path is different from the path of the existing PHP5.2, if the path of the existing PHP5.2 is / usr/local/php5, you can compile the PHP5.3.
. / configure-prefix=/usr/local/php53-with-apxs2=/usr/local/apache2/bin/apxs
-- prefix=/usr/local/php53
Indicates that the new PHP5.3 is installed under the / usr/local/php53 path
-- with-apxs2=/usr/local/apache2/bin/apxs
Indicates that it is still compiled and configured using the existing apache2
After the compilation and installation is complete, a lot of files are generated under / usr/local/php53 and a new libphp5.so is generated under / usr/local/apache2/modules. Compare the file volume, which is much larger than the libphp526.so you just backed up.
4. Configure Apache2 to support different versions of PHP
Stop the apache service first.
Edit httpd.conf and find
LoadModule php5_module modules/libphp5.so
Delete this line and add the following paragraph
LoadModule php5_module modules/libphp5.so
LoadModule php5_module modules/libphp526.so
Then start apache with the-D parameter, such as
/ usr/local/apache2/bin/apachectl-D php53-k start
Then Apache will call this section in httpd.conf to load the libphp5.so of the newly generated PHP5.3. Similarly, if
/ usr/local/apache2/bin/apachectl-D php526-k start
Then Apache will call this section in httpd.conf to load the libphp526.so of the backup PHP5.2.
Open a phpinfo () information page in your browser and take a look at the PHP information. You should be able to see different versions of the PHP information.
5. Update the soft link of the PHP path
PHP also needs to add an extension to PHP and have the command line execute a new version of PHP5.3. All we have to do is update the soft link in the PHP path.
# rm-f / usr/php/default
# ln-s / usr/local/php53 / usr/php/default
Then the command line executes
$php-version
Can output PHP 5.3.6 (cli) and the like, indicating that soft links and environment variables have supported the new version.
Then compile and install the extension of PHP and you can use phpize directly instead of the absolute path with PHP5.3.
6. Switch PHP version
Combining the above operations, if you want to PHP5.3, let / usr/php/default point to / usr/local/php53, and use it when starting Apache.
/ usr/local/apache2/bin/apachectl-D php53-k start
If you want PHP5.2, let / usr/php/default point to / usr/local/php5 and use it when starting Apache.
/ usr/local/apache2/bin/apachectl-D php526-k start
The above is all the contents of the article "how to install PHP5.2 and PHP5.3 on one machine at the same time". 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.