Home>Article>Backend Development> MAC environment installation php, apache, MacPorts and other environment configurations
When I started using the Mac environment, I felt very helpless because I used Windows before and I only knew some simple Mac commands. On the first day I entered the company, I had to configure the Mac environment. I checked a lot of Mac installations online. Environment articles, but the installation was not successful. Maybe those articles were not comprehensive enough for novices. Below I have compiled a note on installing the PHP environment for novices to refer to. If novices don’t know how to install it, just follow the steps in my notes.
1. Install the necessary software
1. To install MacPorts, you need to install X11 and Xcode first (X11 is already installed by default in Lion system), install it in the Appstore Just use Xcode.
After downloading Xcode, the general path is under /Application. You can copy it out for subsequent use:
$ cp -a /Application/Xcode.app ~/soft2.
2. Install MacPort
1. Download address:https://distfiles.macports.org/MacPorts/
MacPort manual download address:https://www.macports.org/install.php
You can directly download the latest version under Lion:https://distfiles.macports.org/MacPorts/MacPorts-2.4.2-10.12-Sierra.pkg
If a new version of MacPort appears, you can update it directly through the following command: $ sudo port -v selfupdate
Add MacPort to the environment variable sudo vim /etc/profile
export PATH=/opt/local/bin:$PATH export PATH=/opt/local/sbin:$PATH
2. Error solution, 1) Set the path of xcode-select, 2) Install the command line tool:
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
3. Apache installation configuration
1.port Install apache:
$ sudo port install apache2 cd /opt/local/etc/apache2/ sudo vim httpd.conf LoadModule rewrite_module lib/apache2/modules/mod_rewrite.so
Four, PHP installation configuration
1. Port to install the PHP environment, I install the version of PHP 5.6.40
$ sudo port install php56-apache2handler
Download, the following prompts
cd /opt/local/lib/apache2/modules sudo /opt/local/bin/apxs -a -e -n php5 mod_php56.so
2. Add the php module to apache, as prompted above, and execute the command prompted above.
$ cd /opt/local/lib/apache2/modules $ sudo /opt/local/bin/apxs -a -e -n php5 mod_php56.so
If you use multiple PHP versions and want to switch PHP versions and mount apache (the following operations are not recommended for beginners and can be ignored)
[Note: httpd.conf manually add the PHP module Mount with apache:
LoadModule php5_module lib/apache2/modules/mod_php56.so #注释打开
3. Install the php extension, select the extension as needed
$ sudo port install php56-mbstring $ sudo port install php56-ftp $ sudo port install php56-iconv $ sudo port install php56-openssl $ sudo port install php56-mcrypt $ sudo port install php56-soap $ sudo port install php56-sqlite $ sudo port install php56-xsl $ sudo port install php56-zip $ sudo port install php56-xdebug $ sudo port install php56-mongo $ sudo port install php56-mysql $ sudo port install php56-oracle $ sudo port install php56-postgresql (php56-mbstring,php56-ftp,php56-iconv,php56-openssl,php56-mcrypt ,php56-soap ,php56-sqlite, php56-xsl ,php56-zip,php56-xdebug,php56-mongo,php56-mysql,php56-oracle,php56-postgresql)
When installing the php56-oracle extension, please note that basic and sdk cannot be downloaded when the port is automatically installed. Need Manually download and put it in the corresponding path:
You can find the corresponding path according to the log prompted when installing $ sudo port install php56-oracle
/opt/local/var/macports/distfiles/oracle-instantclient
The following URL is used to manually download the basic and sdk of oracle
https://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
I downloaded the following version
instantclient-basic-macos.x64-11.2.0.4.0.zip instantclient-sdk-macos.x64-11.2.0.4.0.zip
Put the downloaded compressed package to the following path
cp instantclient-sdk-macos.x64-11.2.0.4.0.zip /opt/local/var/macports/distfiles/oracle-instantclient
4. Edit the httpd.conf file
$ sudo vim /opt/local/etc/apache2/httpd.conf
Add the following code to line 119
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
or
SetHandler application/x-httpd-php
5. Open the virtual directory and edit the httpd.conf file
sudo vim /opt/local/etc/apache2/httpd.conf Include conf/extra/httpd-vhosts.conf #把这个注释去掉
6. Edit the httpd.conf file and change it to:
Options FollowSymLinks AllowOverride none Order deny,allow Allow from all Satisfy all #Require all denied AllowOverride All Options None Options FollowSymLinks Require all granted
7. Edit the httpd.conf file and change the line of codeServerName www.localhost.com:80
Change toServerName localhost:80
8. Configure the php.ini file
cd /opt/local/etc/php56 sudo cp php.ini-production php.ini
I have installed the above steps successfully. Just follow the steps above to install them step by step. , if you don’t understand something, you can leave a message. Thanks.
Everyone supports it. Hope it can help Xiaobai.
The above is the detailed content of MAC environment installation php, apache, MacPorts and other environment configurations. For more information, please follow other related articles on the PHP Chinese website!