Recently I deployed a laravel project under mac os. I have always heard that configuring php + apache + mysql on mac is very simple, but I still have a lot of troubles for those who are not familiar with it. At the beginning, MAMP was installed, and I thought it was as simple as the integrated environment on Windows. As a result, I still encountered many problems. Finally, brew was used. brew installation:
ruby -e "$ (curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
You can see more information on the official website: http://brew.sh, which is very convenient for installing and managing various software. Also, it is better for everyone to install xcode, because sometimes the installation may prompt that some files are missing. Many online solutions are found under xcode and then establish a synchronization link.
php configuration
First install autoconf and mcrypt with brew, then download and decompress the php source code, and choose the corresponding version according to your own situation. (Note the version of php in the following command). You can use php -v to check the version of php. The terminal executes the following commands in sequence:
cd php-5.4.17 / ext / mcrypt /
/ usr / bin / phpize
./configure
make
sudo make install
appear:
Build complete.
It means success.
If phpize has the following error:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include / usr / include grep:
To be honest, brew install autoconf.
* If make has the following error:
/ext/mcrypt/mcrypt.c:25:10: fatal error: 'php.h' file not found sudo ln -s
Just execute the following command:
/usr/include/php/main/php.h: No such file or directory grep: /usr/include/php/Zend/zend_modules.h: No such file or directory grep: / usr / include / php / Zend / zend_extensions .h: No such file or directory Configuring for: PHP Api Version: Zend Module Api No: Zend Extension Api No: Cannot find autoconf. Please check your autoconf installation and the $ PHP_AUTOCONF environment variable. Then, rerun this script.
So everyone still installs xcode.
Finally, open php.ini, it seems that at first there is only php.ini.default, you can just copy it out.
sudo vi /etc/php.ini
Add the following code: (note the no-debug-non-zts-20121212 version number, if not clear, you can go to / usr / lib / php / extensions / to view)
extension = <span style = "font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, STHeiti, 'Microsoft Yahei', sans-serif;"> / usr / lib / php / extensions / no-debug -non-zts-20090626 / </ span> <span style = "font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, STHeiti, 'Microsoft Yahei', sans-serif;"> mcrypt.so </ span>
Apache configuration
The configuration of apache is relatively simple. The apache configuration file is in /etc/apache2/httpd.conf. It is best to make a backup before modification. Sudo vi httpd.conf is opened for modification. Of course, it is only modified when necessary. The documentroot of apache is under / Library / WebServer / Document by default, you just need to put the project in.
Some commands of apache: sudo apachectl start; sudo apachectl stop; sudo apachectl restart.
There is a little episode here. I came across the prompt "You don't have permission to access / on this server.", Which literally means that we don't have permission to access this server. The reason may be that the virtual host is turned on, and then Is deny from all configured? Or storage does not have permissions? Or is the apache configuration file missing the configuration response file name :?
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php server.php
</ IfModule>
How to solve it in the end is not quite remembered, the reasons may be listed above.
Mysql configuration
Still brew, execute: [plain] view plaincopy
brew install mysql
Configuration: [plain] view plaincopy
mysql_install_db --verbose --user = `whoami` --basedir =" $ (brew --prefix mysql) "--datadir = / usr / local / var / mysql --tmpdir = / tmp
After the execution is complete, you can run the mysql command in the terminal. Set mysql to boot, everyone changes according to their version:
[plain] view plaincopy
mkdir -p ~ / Library / LaunchAgents /
cp /usr/local/Cellar/mysql/5.6.26/homebrew.mxcl.mysql.plist ~ / Library / LaunchAgents /
launchctl load -w ~ / Library / LaunchAgents / homebrew.mxcl.mysql.plist
laravel deployment
The previous deployment was changed too messy, after reproducing from svn checkout, composer was installed: [plain] view plaincopy
curl -sS https://getcomposer.org/installer | php
Official website: http://www.getcomposer.org, and found an error during installation: [plain] view plaincopy
file_put_contents (/ Library / WebServer / Documents / www / developed-101 / app / stor
age / views / 9c36d0e7dfaf852919af8da5a89f89a): failed to open stream: No such
file or directory
So I created the views folder. Then it succeeded.
As a result, I finally found that accessing localhost will directly display the index.php page. I do n’t know the reason, but I accidentally found that using php artisan serve can also open the service access project. Then just do it first. Where is the apache configuration missing? Everyone knows, please guide me, thank you.
Copyright statement: This article is an original article by bloggers and may not be reproduced without the permission of the bloggers.
laravel project notes under mac os