Upgrade Php+apache under Mac

Source: Internet
Author: User

The MAC comes with PHP + Apache. But the version is not up-to-date. On the internet for half a day have not found a better case. Had to ponder for a long time.

PHP is 5.4 in my book, and Apache is 2.2. Yesterday in the practice of PHP, encountered a feature, PHP5.4 not supported. Had to go under the upgrade.

It is recommended to use Macport to download and install, mainly to facilitate management.

Install PHP

sudo port install php55;

After installing the PHP55, you will find that after entering PHP at the command line, pressing TAB will appear php55 the relevant files, the original PHP version, no numbers. How to clear the original version at this time, my method is rather stupid. I moved the things in/usr about PHP to somewhere else. The PHP-related execution file is replaced by Ln.

Installing Apache2

sudo port install apache2

The default apachectl is under/usr/sbin, after installation, the new is in/opt/local/apache2. Again I removed the original Apache from/usr.

Installing Apache's PHP module

sudo port install Php55-apache2handler

Install Apache support for PHP. You will be prompted when the installation is complete.

Cd/opt/local/apache2/modulessudo/opt/local/apache2/bin/apxs-a-e-n php5 mod_php55.so

By the time you get into Apache's module directory, you'll find a mod_php55.so.


Some replacements are required after installation, such as replacing PHP with Php55,apachectl and replacing it with the latest! Modify Apache's http.conf, and PHP's php.ini.

The http.conf and php.ini that the Mac comes with can be replaced. After I bring my own backup, it's all erased.


Installing phpMyAdmin

sudo port install phpMyAdmin. If the hint is not phpmyadmin, then port search. Find the right registration.

The installed directory is under/opt/local/www. It needs to be placed in Apache's working directory before it can be used.


Finally, when you run PHP, you will find that there are fewer PHP extensions, such as mbstring. This time with Port search Php55 | grep mbstring. Locate the corresponding extension, and then port install. Missing MySQL on port search Php55 | grep MySQL


View Web page discovery, PHP page display is the source code. Later verified, found that the original PHP file type is less support. Review your Mac's original configuration, and then make your changes.

Configure Http.conf.

Need to add support for PHP files, in the last add these, otherwise open the PHP page, the display is the source code.

<ifmodule php5_module> addtype application/x-httpd-php. php addtype application/x-httpd-php-source. Phps &L T;ifmodule dir_module> directoryindex index.html index.php </IfModule></IfModule>


Upgrade Php+apache under Mac

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.