mac upgrade php7 series of problems and Solutions

Posted by Scriptmaker on Mon, 08 Jul 2019 23:42:08 +0200

Causes:

Because the computer has its own php 5.3, try to run a php project, database import, and configuration file modification is not a problem, but the final error:

Message: Cannot modify header information - headers already sent by  ...

Search for information: According to the following blog try in n ways http://www.dabu.info/warning_can_not_modify_header_information_-_headers_already_sent_b_.html

Last but not least, the php version should be too low and upgraded to php 7.0 directly according to the project description.

$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0

$ php --version  // php 5.3 has not been replaced

$ sudo apachectl stop

$ export PATH=/usr/local/php5/bin:$PATH

$ php --version  // php 7.0.13 

$ sudo apachectl restart

 

Error: Your Xcode (7.3.1) is too outdated.
Please update to Xcode 8.3 (or delete it).

Update Xcode to support php7

Happy to enter localhost in the browser has not succeeded. (Later when I wrote this article, I thought that apache's httpd.conf did not make the corresponding modifications.) Seeing that it did not succeed, the first reaction was the egg, now the php environment can not run itself and there is a php project front-end need to be developed...

Managing php apache through brew

Considering that the later version of php often needs to be switched, brew is used to facilitate the management of php version switching. The installation and introduction of brew are introduced.

http://www.jianshu.com/p/4e80b42823d5

Bullshit without adding php apache warehouse

$ brew tap homebrew/apache
$ brew tap homebrew/php

Install php apache

$ brew install httpd24

$ brew install php70

First close apache

sudo apachectl stop

Modify Apache configuration file, open / usr/local/etc/apache2/2.4/httpd.conf text and add it at last

# ====php module====
LoadModule php7_module /usr/local/Cellar/php70/7.0.17_9/libexec/apache2/libphp7.so
<IfModule mod_php7.c>
 
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
 
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>

Change listening port 8080 to 80

listen 80

Start apache

$ sudo apachectl start

Report errors:

httpd: Syntax error on line 192 of /usr/local/etc/apache2/2.4/httpd.conf: Cannot load /usr/local/Cellar/php70/7.0.17_9/libexec/apache2/libphp7.so into server: dlopen(/usr/local/Cellar/php70/7.0.17_9/libexec/apache2/libphp7.so, 10): image not found

Continue to search the problem google: brew Cannot load libphp7.so error report, the results need to add parameters, the reason is not said.

$ brew install php70 --with-apxs2  --with-apache --with-gmp --with-imap --with-tidy --with-debug,()

$ brew update
$ brew reinstall php70 --with-apxs2  --with-apache --with-gmp --with-imap --with-tidy --with-debug

Continue the error-solving connection: https://github.com/Homebrew/homebrew-php/issues/3736 Solution: (8 minutes or so)

$ xcode-select --install

Continue installing php7 after completion

$ brew update
$ brew reinstall php70 --with-apxs2  --with-apache --with-gmp --with-imap --with-tidy --with-debug

Wait about 10 minutes for installation to complete

$ brew list
apr		httpd24		libxml2		readline
apr-util	icu4c		maven		unixodbc
freetype	imap-uw		mongodb		zlib
gettext		jpeg		openssl
git		libevent	pcre
gmp		libpng		php70

php70 is installed smoothly!

Installed for 40 minutes, too long to wait, it is recommended to change the mirror, here to the source of coding

$ cd /usr/local && git remote set-url origin https://git.coding.net/homebrew/homebrew.git

$ cd $home && brew update

Continue to modify the Apache configuration file/usr/local/etc/apache2/2.4/httpd.conf

DocumentRoot "/Users/lph/Sites"
<Directory "/Users/lph/Sites">

Road Strength Customization.

Next, browser input validation: localhost / project name/

Topics: PHP brew Apache sudo