这篇文章主要为大家详细介绍了mac安装nginx和php的简单示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小玲来看看吧!
一、前话:代码如下:
#打开 nginx
sudo nginx
代码如下:
mkdir -p ~/Library/LaunchAgents/
cp /usr/local/Cellar/nginx/1.4.2/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
代码如下:
2
sudo chown root:wheel /usr/local/Cellar/nginx/1.4.2/bin/nginx
sudo chmod u+s /usr/local/Cellar/nginx/1.4.2/bin/nginx
代码如下:
brew install mysql
代码如下:
sudo mysql_install_db \
--verbose --user=`whoami` \
--basedir="$(brew --prefix mysql)" \
--datadir=/usr/local/var/mysql \
--tmpdir=/tmp \
--explicit_defaults_for_timestamp
代码如下:
sudo rm /usr/local/opt/mysql/my.cnf
sudo rm -R /usr/local/var/mysql/
代码如下:
/usr/local/opt/mysql/bin/mysqld_safe &
代码如下:
/usr/local/opt/mysql/bin/mysqladmin -u root password 'new-password'
代码如下:
/usr/local/opt/mysql/bin/mysql_secure_installation
代码如下:
mysql -u root -p
代码如下:
mkdir -p ~/Library/LaunchAgents/
cp /usr/local/Cellar/mysql/5.6.13/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
代码如下:
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
代码如下:
sudo brew install php55 \
--with-debug \
--with-fpm \
--with-gmp \
--with-homebrew-openssl \
--with-imap --with-intl \
--with-libmysql \
--without-bz2 \
--without-mysql \
--without-pcntl \
--without-pear
代码如下:
export PATH="$(brew --prefix php54)/bin:$PATH"
[html]
[code]
source ./.profile
代码如下:
mkdir -p ~/Library/LaunchAgents/
cp /usr/local/Cellar/php54/5.5.3/homebrew-php.josegonzalez.php55.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist
代码如下:
#!/bin/sh
param=$1
start()
{
fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk '{print $2}'`
if [ ! -n "$fpms" ]; then
php-fpm
echo "PHP-FPM Start"
else
echo "PHP-FPM Already Start"
fi
}
stop()
{
fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk '{print $2}'`
echo $fpms | xargs kill -9
for pid in $fpms; do
if echo $pid | egrep -q '^[0-9]+$'; then
echo "PHP-FPM Pid $pid Kill"
else
echo "$pid IS Not A PHP-FPM Pid"
fi
done
}
case $param in
'start')
start;;
'stop')
stop;;
'restart')
stop
start;;
*)
echo "Usage: ./phpfpm.sh start|stop|restart";;
esac
代码如下:
server {
listen 80;
server_name localhost;
index index.html index.htm index.php;
......
}
代码如下:
location ~ .*\.(php|php5)?$ {
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /Library/WebServer/public_html$fastcgi_script_name;
include /usr/local/etc/nginx/fastcgi_params;
#include fcgi.conf;
}
代码如下:
sudo chown www:www /Library/WebServer/public_html
代码如下:
<?php
/* 四海网 www.q1010.com */
phpinfo();
本文来自:http://www.q1010.com/173/14655-0.html
注:关于mac安装nginx和php的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。