osx下的mamp环境部署

2015-12-19

osx下的php环境部署

osx默认集成php+apache2 1. 启动apache2
sudo apachectl start
查看apache2版本
httpd -v
默认网站目录
/Library/WebServer/Document/
2. 开启虚拟机
sudo vim /etc/apache2/httpd.conf
取消#include /private/etc/apache2/extra/httpd-vhost.conf的注释
注释#Require all denied
3. 添加虚拟机
sudo vim /etc/apache2/extra/httpd-vhosts.conf
虚拟机启用后默认网站目录失效,需手动添加127.0.0.1 or localhost所对应的目录
<VirtualHost *:80> ServerAdmin admin@uuuuj.com DocumentRoot "/Users/Tinty/Documents/Sites/tinblog/public/" ServerName localhost ErrorLog "/Users/Tinty/Documents/Sites/logs/errors" CustomLog "/Users/Tinty/Documents/Sites/logs/customlog" common </VirtualHost> <VirtualHost *:80> ServerAdmin admin@uuuuj.com DocumentRoot "/Library/WebServer/Documents/" ServerName 127.0.0.1 ErrorLog "/Users/Tinty/Documents/Sites/logs/errors" CustomLog "/Users/Tinty/Documents/Sites/logs/customlog" common </VirtualHost> 重启apache2 4. 开启php
sudo vim /etc/apache2/httpd.conf
取消LoadModule php5_module libexec /apache2/libphp5.so的注释
5. 安装mysql
官网下载并安装
启动mysql
sudo /usr/local/mysql/support-files/mysql.server start
查看mysql版本
/usr/loal/mysql/bin/mysql -v
将mysql添加至环境变量使其在任何位置可以使用
sudo vim ~/.bash_profile
添加export PATH="/usr/local/mysql/bin:$PATH"
source ~/.bash_profile
6. 安装mcypt扩展
brew install mcrypt
brew install php55-mcrypt
链接ext-mcrypt.ini 详细可见http://www.tuicool.com/articles/6NVFZz
sudo mkdir -p /Library/Server/Web/Config.php
sudo ln -s /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini /Library/Server/Web/Config/php/ext-mcrypt.ini
重启apache2
7. 配置php的mysql连接池
sudo vim /usr/local/etc/php/5.5/php.ini
修改
mysql.default_socket = /tmp/mysql.sock
pdo_mysql.default_socket= /tmp/mysql.sock
mysqli.default_socket =/tmp/mysql.sock
8. 其他
通过brew重新安装php后需要重新配置httpd.conf中的LoadModule php5_module/usr/local/Cellar/php55/5.5.30/libexec/apache2/libphp5.so

mysql启动报错

the server quit without update pid 无意中在systerm preferences中直接启动mysql成功

strpos()

strpos()当匹配的元素恰好是第0位置的时候,返回0,所以在验证是否有元素存在时if(strpos())改成if(strpos()||strpos()===0)

ajax换url,后退前进功能暂无

var state={ url:url, title:title, }; window.history.pushState('state','xxxxx',url);

61 查看