[转] mac El Capitan 中安装 PHP 开发环境

https://getgrav.org/blog/mac-os-x-apache-setup-multiple-php-versions

 

Part 1: OS X 10.11 El Capitan Web Development Environment

Developing web applications on OS X is a real joy. There are plenty of options for setting up your development environments, including the ever-popular MAMP Pro that provides a nice UI on top of Apache,PHP and MySQL. However, there are times when MAMP Pro has slow downs, or out of date versions, or is simply behaving badly due to its restrictive system of configuration templates and non-standard builds.

It is times like these that people often look for an alternative approach, and luckily there is one, and it is relatively straight-forward to setup.

In this blog post, we will walk you through setting up and configuring the OS X built-in Apache and multiple PHP versions. In the second blog post in this two-post series, we will cover MySQL, Apache virtual hosts,APC caching, and Xdebug installation.

This post was updated 10/22/2015 to reflect OS X 10.11 El Capitan rather than OS X 10.10 Yosemite. If you had this setup working with OS X 10.10 Yosemite, and have upgraded to 10.11 El Capitan, you will need to perform the httpd.conf changes again as the upgrade process overwrites the file. Also you will have to fix homebrew as outlined below as permissions on /usr/local directory are modified in such a way that brew will not working 100%.

This guide is intended for experienced web developers. If you are a beginner developer, you will be better served using MAMP or MAMP Pro.

Apache Setup

OS X 10.11 El Capitan comes with the Apache 2.4 pre-installed, but there is no longer a Web Sharingpreference pane in the System Preferences.

Not to fret! A simple Web sharing preference pane is available from clickontyler.com. This is a scaled down free version of the more powerful VirtualHostX. VirtualHostX is a pretty UI for controlling Apache, but you don’t really need it.

Another approach is simply to use the provided apachectl command from your terminal. Using the terminal is a pretty scary prospect for many people, but there’s no need to fear it.

To start up the web server, simply bring up the Terminal (/Applications/Utilities/Terminal) and type:

$ sudo apachectl start

To stop apache you would type:

$ sudo apachectl stop

To restart apache when you have made configuration changes, simply type:

$ sudo apachectl -k restart

The -k will force a restart immediately rather than asking politely to restart when apache is good and ready

So start Apache now, and then try to reach your server in a browser by pointing it at your localhost, you should see a simple header that says It works!.

If you cannot reach your site via http://localhost you might need to add an alias in your/etc/hosts file: 127.0.0.1 localhost. It should exist by default.

Document Root

The first thing we will want to do is to change the document root for Apache. This is the folder where Apache looks to serve file from. By default, the document root is configured as/Library/WebServer/Documents. As this is a development machine, let’s assume we want to change the document root to point to a folder in our own home directory. To do this, we will need to edit Apache’s configuration file.

/etc/apache2/httpd.conf

You can use whatever command line editor you are comfortable with, just realize this is a root-ownedfolder so you will need to use sudo to be able to edit and save the file. I prefer to use Sublime Text 3with the commandline command subl, others will probably prefer vi but If you have never used a command line editor, try nano:

$ sudo nano /etc/apache2/httpd.conf

Nano Editor

Search for the term DocumentRoot, and you should see the following line:

DocumentRoot "/Library/WebServer/Documents"

Change this to point to your user directory where your_user is the name of your user account:

DocumentRoot "/Users/your_user/Sites"

You also need to change the <Directory> tag reference right below the DocumentRoot line. This should also be changed to point to your new document root also:

<Directory "/Users/your_user/Sites">

In that same <Directory> block you will find an AllowOverride setting, this should be changed as follows:

AllowOverride All

User & Group

Now we have the Apache configuration pointing to a Sites folder in our home directory. One problem still exists, however. By default, apache runs as the user _www and group _www. This will cause permission problems when trying to access files in our home directory. About a third of the way down thehttpd.conf file there are two settings to set the User and Group Apache will run under. Change these to match your user account (replace your_user with your real username), with a group of staff:

User your_user
Group staff

PHP 7.0 Additional Changes

Although this is not needed for PHP 5.X, it is needed for PHP 7.0 and as we cover that below it’s safer to just add it now. So scroll down until you see something like:

<FilesMatch "^\.([Hh][Tt]|[Dd][Ss]_[Ss])">
    Require all denied
</FilesMatch>

Below this paste the following:

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Also you must set the Directory Indexes for PHP explicitly, so search for this block:

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

and replace it with this:

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

Save the file.

Create a Sites Folder

Of course you will now need to restart your Apache with sudo apachectl restart to pick up the changes you just made to the configuration file.

Now, you need to create a Sites folder in the root of your home directory. You can do this in your terminal, or in Finder. In this new Sites folder create a simple index.html and put some dummy content in it like: <h1>My User Web Root</h1>.

$ mkdir ~/Sites
$ echo "<h1>My User Web Root</h1>" > ~/Sites/index.html

Restart apache to ensure your configuration changes have taken effect:

$ sudo apachectl -k restart

Pointing your browser to http://localhost should display your new message. If you have that working, we can move on!

Homebrew

This process relies heavily on the OS X package manager called Homebrew. Using the brew command you can easily add powerful functionality to your mac.

Xcode 7.1 and the Command Line Tools are required so make sure you install Xcode via the Mac App Store first. Launch Xcode and agree to the Terms and Conditions, then install the Command Line Tools with this command:

xcode-select --install

Xcode Installation

Installation

The full installation documentation can be found on the Homebrew Wiki, but we will cover the essentials. Install the homebrew with the following command in your terminal:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Just follow the terminal prompts and enter your password where required. This may take a few minutes, but when complete, a quick way to ensure you have installed brew correctly, simply type:

$ brew --version

Verification

You should probably also run the following command to ensure everything is configured correctly:

$ brew doctor

It will instruct you if you need to correct anything.

If you had this setup working previously with OS X 10.10 Yosemite and have upgraded to 10.11 El Capitan, you will get an error concerning the permissions on /usr/local due to new SIP changes in El Capitan. To address this simply run: sudo chown -R $(whoami):admin /usr/local

If you already have brew installed, make sure you have the all the latest available brews:

$ brew update

Now you are ready to brew!

Install PHP 5.4, 5.5, 5.6, 7.0

Now we have HomeBrew installed it is a simple procedure to install PHP. We will proceed by installing bothPHP 5.4, PHP 5.5, PHP 5.6, and PHP 7.0 and using a simple script to switch between them as we need. First though we have to tap into the PHP formulas and run the following commands.

You can get a full list of available options to include by typing brew info php54, for example. In this example we are just including MySQL support (required for Joomla, WordPress, etc.)

$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
$ brew install php54
$ brew unlink php54
$ brew install php55
$ brew unlink php55
$ brew install php56
$ brew unlink php56
$ brew install php70

Of course you can choose which versions to install. You many not need all the PHP versions listed above.

This may take some time as your computer is actually compiling Apache.

NOTE: If you get an error during compilation: configure: error: Cannot find OpenSSL's <evp.h> you need to reinstall your Xcode command line tools with: xcode-select --install

Also, you may have the need to tweak configuration settings of PHP to your needs. A common thing to change is the memory setting, or the date.timezone configuration. The php.ini files for each version of PHP are located in the following directories:

/usr/local/etc/php/5.4/php.ini
/usr/local/etc/php/5.5/php.ini
/usr/local/etc/php/5.6/php.ini
/usr/local/etc/php/7.0/php.ini

Apache Setup

You have successfully installed your PHP versions, but we need to tell Apache to use them. You will again need to edit the /etc/apache2/httpd.conf file and search for #LoadModule php5_module. You will notice that this is line is commented out. We can ignore it because this is pointing to the version of PHP that came with OS X. Below the other LoadModule lines, add this:

# Brew PHP LoadModule
LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so

This will tell Apache to use PHP 5.4 to handle PHP requests. We will add the ability to switch PHP versions later.

You should also take this time to uncomment the mod_rewrite.so module definition so that it will be available:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

Let’s restart Apache again, now that we have installed PHP:

$ sudo apachectl restart

Validating PHP Installation

The best way to test if PHP is installed and running as expected is to make use of phpinfo(). This is not something you want to leave on a production machine, but it’s invaluable in a development environment.

Simply create a file called info.php in your Sites/ folder you created earlier. In that file, just enter the line:

<?php phpinfo();

Point your browser to http://localhost/info.php and you should see a shiny PHP information page:

PHPInfo()

If you see a similar phpinfo result, congratulations! You now have Apache and PHP running successfully.

PHP Switcher Script

We hard-coded Apache to use PHP 5.4, but we really want to be able to switch between versions. Luckily, some industrious individual has already done the hard work for us and written a very handy little PHP switcher script.

It is useful to have a your own local bin folder in your home directory. We will create one and setup thesphp script:

$ mkdir -p ~/bin/
$ curl -L https://raw.githubusercontent.com/conradkleinespel/sphp-osx/master/sphp > ~/bin/sphp
$ chmod +x ~/bin/sphp

Update Your Path

Now we want to ensure this script is easily found when we are in the terminal, so we need add our/Users/your_user/bin directory to our path, as well as putting HomeBrew’s preferred /usr/local/binand /usr/local/sbin before OS X’s default /usr/bin folder. Depending on your shell your using, you may need to add this line to ~/.profile, ~/.bash_profile, or ~/.zshrc.

We will assume you are using the default bash shell, so add this line to a your .profile (create it if it doesn’t exist) file at the root of your user directory:

export PATH=/usr/local/bin:/usr/local/sbin:$PATH:/Users/your_user/bin

Replace your_user with your actual user account. E.g. /Users/joeschmo/bin

At this point, I strongly recommend closing ALL your terminal tabs and windows. This will mean opening a new terminal to continue with the next step. This is strongly recommended because some really strange path issues can arise with existing terminals (trust me, I have seen it!).

You can double-check and ensure your path has been updated to put the /usr/local paths first with the following command:

$ echo $PATH

Apache Setup – Take 2

Although we configured Apache to use PHP earlier, we now need to change this again to point the PHP module to a location used by the PHP switcher script. You will again need to edit the/etc/apache2/httpd.conf file and search for the Brew PHP text that you added earlier. Edit theLoadModule line, to this:

# Brew PHP LoadModule for `sphp` switcher
LoadModule php5_module /usr/local/lib/libphp5.so
#LoadModule php7_module /usr/local/lib/libphp7.so

It is important that you remove all other commented out LoadModule php5_module entries at this point or it will confuse the sphp switcher. Also the Commented out line for php7_module is important and required if you are installing PHP7 as it uses a unique PHP module handler.

IMPORTANT: Switch to your PHP 5.4 version with the sphp switch command :

$ sphp 54
PHP version 54 found
Unlinking old binaries...
Linking new binaries...
Linking /usr/local/Cellar/php54/5.4.45_3... 17 symlinks created
Linking new modphp addon...
Fixing LoadModule...
Updating version file...
Restarting system Apache...
Done.

Testing the PHP Switching

After you have completed these steps, you should be able to switch your php version by using the command:

$ sphp 55

You will probably have to enter your administrator password, and it should give you some feedback:

PHP version 55 found
Unlinking old binaries...
Linking new binaries...
Linking /usr/local/Cellar/php55/5.5.30... 17 symlinks created
Linking new modphp addon...
Fixing LoadModule...
Updating version file...
Restarting system Apache...
Done.

Test to see if your Apache is now running PHP 5.5 by again pointing your browser tohttp://localhost/info.php. With a little luck, you should see something like this:

PHPInfo()

Updating PHP and other Brew Packages

Brew makes it super easy to update PHP and the other packages you install. The first step is to update Brew so that it gets a list of available updates:

$ brew update

This will spit out a list of available updates, and any deleted formulas. To upgrade the packages simply type:

$ brew upgrade

You will need to switch to each of your installed PHP versions and run update again to get updates for each PHP version and ensure you are running the version of PHP you intend.

Activating Specific/Latest PHP Versions

Due to the way our PHP linking is set up, only one version of PHP is linked at a time, only the current activeversion of PHP will be updated to the latest version. You can see the current active version by typing:

$ php -v

And you can see the specific versions of PHP available by typing:

$ brew info php55
homebrew/php/php55: stable 5.5.30 (bottled), HEAD
https://php.net
Conflicts with: php53, php54, php56, php70
/usr/local/Cellar/php55/5.5.28 (498 files, 51M)
  Poured from bottle
/usr/local/Cellar/php55/5.5.29_3 (327 files, 49M)
  Poured from bottle
/usr/local/Cellar/php55/5.5.30 (327 files, 49M)
  Poured from bottle
  ...

You will see all the versions of PHP 5.5 brew has available and then you can switch to a specific version by typing:

$ brew switch php55 5.5.28

OK, that wraps up Part 1 of this 3 part series You now have a fully functional Apache 2.4 installation with a quick-and-easy way to toggle between PHP 5.4, 5.5, 5.6, and 7.0. Check out Part 2 to find out how to setup your environment with MySQL, Virtual Hosts, APC caching, YAML, and Xdebug. Also take a gander at Part 3to find out how to setup SSL for your Apache Virtual Hosts.

 

889 total views, no views today

[转] 404 页面设计 404 Page Inspiration

https://medium.com/muzli-design-inspiration/404-page-inspiration-de4ec8618693#.fhueqx8rz

 

404 Page Inspiration

via Muzli design inspiration

Awesome Kit “404” illustration by Awesomed

404 by Arthur MB
Missing File by Zach Graham for Dropbox

404 — funky monkey by Tony Babel
Tubik Studio | Page 404 by Ernest Asanov for Tubik Studio
404 Page by Timothy J. Reynolds for Twitch
Dropbox Community : 404 by UENO
404 — Uh oh! by Andrew Colin Beck
404 — OMG! by Andrew Colin Beck
No Bananas here by John Torres ♖♜ for Nutanix
V2 by Halvor Nordrum
404 Page Not Found! by Adheedhan Ravikumar
404 error by Aleksandr Romanukha
#3 404 Page by Denis Abdullin
404 by Jeff Lupinski
404 bulb by Eddie Lobanovskiy
404 error page. Atech psd template by Olia Gozha
Error, Location not found ! by Ghani Pradita
404 by Olga Baydalinova
404 page by Viktor Kern
Daily UI 008: 404 Page by Abhas Sinha
404 by Oleg Frolov
404 page with an inspiring quote by Andrew
UI challenge — 404 page #008 +PSD by This Optimism
404 Get Lost by Anthony Lagoon for Underbelly
404 by Seán Halpin

Oops! by Airbnb
Foodly 404 by Olia Gozha for Congruity Hub
404 concept by Daniel Haire for Yik Yak
Page Cannot Be Found by Lumen Bigott for Eventbrite
Page 404 by Ilja Miskov for Peppers
Heyllow New Website by Valentine Boyev for Heyllow
4 oh.. 4 by Justas Galaburda for Studio4 | Creative

404 Page by Frank Rodriguez
Daily UI — 404 Error Page! by Victor Belinatti
Day 8: 404 by Julius Koroll
404 Page by Ryan Duffy
Daily UI #24 — Error 404 by Patryk Wąsik for Symu.co

#dailyui by Pete Lacey
Daily UI: Day 8–404 Page by matt rossi
100 Days Sketch UI Contest #day008–404 Error Page by Paweł Łuczak
Daily UI Day #8 by Jonas Verheijden
Day 021 — Error 404 by HEZY
404 page by Roman Menshikov
Daily UI 404 Error by Susana Gonzalez
404 Page by Patryk Zabielski
DailyUI 008: 404 page by Frexy
404 by Danny Groenen
404 page by Roman Menshikov
404 Error Daily UI #008 by Vania Vega

So much more amazing content…

Join over 60,000 others who enjoy Muzli for Chrome.
Muzli is a goldmine of inspiring, beautiful & fresh content, stunningly delivered every time you open up a new tab.

1,328 total views, no views today

[转] Mobile Navigation Inspiration 移动应用的导航设计

惊艳。

转自 https://medium.com/muzli-design-inspiration/mobile-navigation-inspiration-f2a33bcbc9cb#.ikc6l5uky

via Muzli design inspiration

Safari view by Gleb Kuznetsov

Travel Blog App Concept by Anatoliy Nesterov for Yalantis

Tab Bar Animation by Vitaly Rubtsov for Yalantis
Dashboard and Menu by Megan Fox for Notch Interactive

App Navigation by Ramotion

Bottom Nav Experiments by Vitaly Rubtsov for Yalantis
Evernote Skitch iOS by Jesse Guerrero for Evernote Design

Navigation Concept by Steffen Nørgaard Andersen for Magnetix

Shopping List by by Hila Peleg

Trello Navigation by Aurélien Salomon

Navigation by Cuberto

iPad Mini Template (Preview) by Creativedash

UI Navigation Concept by Ludmila Shevchenko for Tubik Studio

Large Screen Navigation by Ramotion

App Navigation Pulldown by ⋈ Sam Thibault ⋈ for Handsome

App Circle Navigation by ⋈ Sam Thibault ⋈ for Handsome

Look flow by Aleksandr Larionov for LUFT

Healthy Choice by Dejan Markovic

Navigation at the bottom by Aurélien Salomon

pSettings fun navigation by Aurélien Salomon

So much more amazing content…

Join over 60,000 others who enjoy Muzli for Chrome.
Muzli is a goldmine of inspiring, beautiful & fresh content, stunningly delivered every time you open up a new tab.

922 total views, no views today

[转] viewport的研究

英文:http://www.quirksmode.org/mobile/viewports.html

中文: http://weizhifeng.net/viewports.html

 

 

934 total views, 1 views today

[转]理发店官网

转一个逼格满满的主页

http://offandon.me/

900 total views, no views today