Upgrade php+apache under Mac

WBOY
Release: 2016-08-08 09:31:09
Original
903 people have browsed it
Mac comes with php + apache. But the version is not the latest. I searched online for a long time but couldn't find any better examples. I had to think about it for a long time.
In my notebook, php is 5.4 and apache is 2.2. Yesterday when I was practicing PHP, I encountered a feature that PHP5.4 does not support. Had to upgrade. It is recommended to use MacPort for downloading and installation, mainly to facilitate management. Install PHP sudo port install php55; After installing php55, you will find that after entering php on the command line and pressing the Tab key, the relevant files of php55 will appear. The original php version does not have number. How do I clear the original version at this time? My method is rather stupid. I moved the PHP stuff under /usr to other places. ln the executable files related to php and replace them. Install apache2
sudo port install apache2
Copy after login

The default apachectl is under /usr/sbin. After installation, the new one is under /opt/local/apache2. Likewise, I removed the original apache from /usr. Install apache’s php module
sudo port install php55-apache2handler
Copy after login

Install apache’s support for php. There will be a prompt after the installation is completed.
cd /opt/local/apache2/modules sudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php55.so
Copy after login
At this time, enter the module directory of apache and you will find an additional mod_php55.so.
After installation, some replacements need to be made, such as replacing php with PHP55 and apachectl with the latest one! Modify apache's http.conf and php's php.ini. The previous http.conf and php.ini that came with Mac can be replaced. After I brought my own backup, I deleted them all. Install phpmyadmin
sudo port install phpmyadmin. 如果提示没有phpmyadmin,那就port search 一下。查找正确的报名
Copy after login
The directory after installation is under /opt/local/www. It needs to be placed in the working directory of apache before it can be used.
Finally, when running PHP, you will find that there are fewer PHP extensions, such as mbstring. At this time, use port search php55 | grep mbstring. Find the corresponding extension and then port install. If mysql is missing, just port search php55 | grep mysql
. Check the web page and find that the php page display is all source code. Later, after verification, it was found that support for the php file type was missing. Check the original configuration of the Mac and then make modifications. Configure http.conf. You need to add support for PHP files. Add these at the end, otherwise when you open the php web page, the source code will be displayed.
 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps  DirectoryIndex index.html index.php  
Copy after login



The above has introduced how to upgrade php + apache under Mac, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!