Each Mac has a built-in Apache server that runs a built-in PHP. Mac os update 10.13 download.
PHP is basically an interpreted language implemented by a web server or CGI executable. In this tutorial, we will learn the steps to install PHP on macOS. MacOS; Login as an administrator on terminal; Homebrew package installer must be configured on the system. 1) Installation of PHP includes following steps. PHP is a server-side, cross-platform, HTML embedded scripting language. If you are new to PHP and want to get some idea of how it works, try the online manual, and the example archive sites.
To upgrade it you need less than 10 minutes once you have understood all the steps needed.
The same applies also to install the last PHP 7.1 version: you only need to change the required version of PHP (see below).
Exploring the LAMP server of a Mac
To understand the built-in PHP of your Mac the first thing you should do is open your terminal and type in:
This is the PHP version installed in your Mac.
But, from where is it executed?
And the php.ini?
So, by default Mac OsX has
PHP 5.5.24 with xDebug 2.2.3 and our php.ini is located at /usr/bin/php . Os x application bundle plugin for maven.
How to update PHP on Mac OsX
As we want to update the built-in version of PHP of our Mac OsX, at this point maybe its better to think at a more valuable solution.
Update PHP… go to php.net/downloads.php, download the latest version of PHP, unzip, compile, configure… Mmm, there is a better solution for sure!
And in fact, those good boys at Liip have thought that there should be a better solution… And they built it!
So, in your Terminal, type (use 7.1 if you want to install the last PHP 7.1 version!):
You have just downloaded the best PHP latest version you can find ever.
Now, let’s configure it: it needs less then 5 minutes!
WARNING: If you receive an error like, then you need to stop the built-in Apache instance and reinstall it from Homebrew: it seems the Apache version shipped with MacOS causes some troubles that prevent the server to starting.
Here all the information you need to disable the built-in version of Apache in MacOS and install a fresh new one with Homebrew. How to configure your updated version of Mac OsX built-in PHP
The package you have just downloaded is a custom version of PHP built by Liip and it provides a lot more functionalities and useful PHP extension than the original Mac OsX built-in PHP, so you will save a lot of time when you’ll install and update them (think at Intl extension or xDebug, for example).
Once downloaded, the Liip’s PHP moves all the files into
/usr/local/php5-5.6.11-20150710-223902/bin and makes a symlink of this folder called php5. In this way, when you’ll update PHP, Apache will automatically load the new PHP version (see more about this in a moment). Really smart!
If you type in Terminal again
which php you’ll get the same result as before. This is because we have to tell our Mac OsX to load PHP from the new location.
To do this we will create a
.bash_profile in our user directory:
This will open VIM that will create the new file (if it is already present, type the letter
a to enter the edit mode).
Into the
.bash_file write the line export PATH=/usr/local/php5/bin:$PATH , then press Esc and type SHIFT + Z for two times (a shortcut to save and close the file).
Then load again the
.bash_profile file and restart Apache:
You have updated your Mac OsX built-in PHP.
On the Liip’s PHP Mac OsX home page you will find a lot of useful information about your new PHP.
![]()
The next step you should do is open the
php.ini located at /usr/local/php5/lib/ and set it the right way.
And, once you have configure your
php.ini , maybe you want to configure your Mac Osx built-in Apache or want to install MySQL in your Mac (as it is not shipped by default).
Remember to “Make. Ideas. Happen.”.
I wish you flocking users, see you soon!
macOS Update: While these instructions still work, there are new posts for recent versions of macOS, the latest being Install Apache, PHP, and MySQL on macOS Mojave.
I have installed Apache, PHP, and MySQL on Mac OS X since Leopard. Each time doing so by hand. Each version of Mac OS X having some minor difference. This post serves as much for my own record as to outline how to install Apache, MySQL, and PHP for a local development environment on Mac OS X
I am aware of the several packages available, notably MAMP. These packages help get you started quickly. But they forego the learning experience and, as most developers report, eventually break. Personally, the choice to do it myself has proven invaluable.
It is important to remember Mac OS X runs atop UNIX. So all of these technologies install easily on Mac OS X. Furthermore, Apache and PHP are included by default. In the end, you only install MySQL then simply turn everything on.
First, open Terminal and switch to
root to avoid permission issues while running these commands.
Enable Apache on Mac OS X
Note: Prior to Mountain Lion this was an option for Web Sharing in System Prefrences → Sharing.
Mac blu ray ripper pro download. Verify It works! by accessing http://localhost
Enable PHP for Apache
OS X Mavericks Update: You will need to rerun the steps in this section after upgrading an existing install to Mac OS X Mavericks.
First, make a backup of the default Apache configuration. This is good practice and serves as a comparison against future versions of Mac OS X.
Now edit the Apache configuration. Feel free to use TextEdit if you are not familiar with vi.
Uncomment the following line (remove
# ):
Restart Apache:
Install MySQL
The README also suggests creating aliases for
mysql and mysqladmin . However there are other commands that are helpful such as mysqldump . Instead, I updated my path to include /usr/local/mysql/bin .
Note: You will need to open a new Terminal window or run the command above for your path to update.
I also run
mysql_secure_installation . While this isn't necessary, it's good practice. Helicopter game free download for phone.
Connect PHP and MySQLDownload Php Mac
You need to ensure PHP and MySQL can communicate with one another. There are several options to do so. I do the following:
Creating VirtualHosts
You could stop here. PHP, MySQL, and Apache are all running. However, all of your sites would have URLs like http://localhost/somesite/ pointing to /Library/WebServer/Documents/somesite. Not ideal for a local development environment.
OS X Mavericks Update: You will need to rerun the steps below to uncomment the vhost
Include after upgrading an existing install to Mac OS X Mavericks.
To run sites individually you need to enable VirtualHosts. To do so, we'll edit the Apache Configuration again.
Uncomment the following line:
Now Apache will load httpd-vhosts.conf. Let's edit this file.
Here is an example of VirtualHosts I've created.
The first
VirtualHost points to /Library/WebServer/Documents . The first VirtualHost is important as it behaves like the default Apache configuration and used when no others match.
The second
VirtualHost points to my dev workspace and I can access it directly from http://jason.local. For ease of development, I also configured some custom logs.
Php Mac Editor
Note: I use the extension local. This avoids conflicts with any real extensions and serves as a reminder I'm in my local environment.
Restart Apache:
In order to access http://jason.local, you need to edit your hosts file.
Add the following line to the bottom: Skype download for mac 10.8.5.
Change default download folder mac. I run the following to clear the local DNS cache:
Update Php On Mac
Now you can access http://jason.local.
Note: You will need to create a new
VirtualHost and edit your hosts file each time you make a new local site.
A note about permissions
You may receive 403 Forbidden when you visit your local site. This is likely a permissions issue. Simply put, the Apache user (
_www ) needs to have access to read, and sometimes write, your web directory.
If you are not familiar with permissions, read more. For now though, the easiest thing to do is ensure your web directory has permissions of
755 . You can change permissions with the command:
In my case, all my files were under my local
~/Documents directory. Which by default is only readable by me. So I had to change permissions for my web directory all the way up to ~/Documents to resolve the 403 Forbidden issue.
Note: There are many ways to solve permission issues. I have provided this as the easiest solution, not the best.
Download Php For MacInstall PHPMyAdminMac Os Php
Unless you want to administer MySQL from the command line, I recommend installing PHPMyAdmin. I won't go into the details. Read the installation guide for more information. I install utility applications in the default directory. That way I can access them under, in this case, http://localhost/phpmyadmin.
Closing
A local development environment is a mandatory part of the Software Development Process. Given the ease at which you can install Apache, PHP, and MySQL on Mac OS X there really is no excuse.
Run Php On Mac
Find this interesting? Let's continue the conversation on Twitter.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |