: This article describes how to upgrade php + apache on Mac. For more information about PHP tutorials, see. Built-in php + apache under Mac. But the version is not the latest. I have not found any good examples on the Internet for half a day. I had to worry about it for a long time.
In my notebook, php is 5.4, and apache is 2.2. When I was practicing php yesterday, I encountered a feature that is not supported by PHP5.4. You have to perform the upgrade.
It is recommended to use MacPort for download and installation, mainly for convenient management.
Install PHP
Sudo port install php55;
After installing php55, you will find that after entering php in the command line, pressing the Tab key will show related php55 files. The original php version has no numbers. How can I clear the original version at this time? my method is stupid. I moved/usr related php to another place. Replace the ln part of the php-related execution file.
Install apache2
sudo port install apache2
The default apachectl is in/usr/sbin. after installation, the new one is in/opt/local/apache2. I also removed the original apache from/usr.
Install apache's php module
sudo port install php55-apache2handler
Install apache's support for php. A prompt will be displayed after the installation is complete.
cd /opt/local/apache2/modulessudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php55.so
In this case, go to the module directory of apache and you will find an additional mod_php55.so.
After installation, replace php with PHP55 and apachectl with the latest version! Modify apache http. conf and php. ini.
Previously, both http. conf and php. ini of Mac can be replaced. I deleted all my backups.
Install phpmyadmin
Sudo port install phpmyadmin. if you are prompted that no phpmyadmin exists, port search. Find the correct registration
The installed directory is in/opt/local/www. You must put it in the apache working directory to use it.
Finally, when running PHP, we will find fewer php extensions, such as mbstring. In this case, use port search php55 | grep mbstring. Find the corresponding extension, and then port install. If mysql is missing, port search php55 | grep mysql
View the web page and find that the php page displays the source code. After verification, we found that the php file type was not supported. View the original Mac configuration and modify it.
Configure http. conf.
You need to add support for php files. add these files at the end. Otherwise, the source code is displayed when you open the php webpage.
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.php
The above describes how to upgrade php + apache on Mac, including some content. I hope my friends who are interested in PHP tutorials can help me.