在mac下编译安装了最新版本namp的环境, 记录一下安装过程, 其实总体和linux下没有太多区别,另外port是个好东西。
mysql编译安装:
1. 建立mysql数据存储目录, 权限设置为mac os默认存在的_mysql权限:
mkdir -p /var/mysql/data/
chown -R _mysql:_mysql /var/mysql/
2. 下载mysql, 我下的版本为mysql-5.5.18, 执行以下跨平台编译命令:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/server/mysql -DMYSQL_DATADIR=/var/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
3. 编译, 安装:
4. 改变mysql目录的权限:
sudo chmod +w /usr/local/server/mysql
sudo chown -R _mysql:_mysql /usr/local/server/mysql
5. 创建库软链接:
sudo ln -s /usr/local/server/mysql/lib/lib* /usr/lib/
6. copy配置文件到etc目录:
cp /usr/local/server/mysql/support-files/my-large.cnf /etc/my.cnf
[client]
default-character-set = utf8
[mysqld]
character-set-server = utf8
default-storage-engine = MyISAM
basedir = /usr/local/server/mysql
datadir = /var/mysql/data
log-error = /var/mysql/mysql_error.log
pid-file = /var/mysql/mysql.pid
7. 建立初始数据表:
sudo /usr/local/server/mysql/scripts/mysql_install_db --basedir=/usr/local/server/mysql --datadir=/var/mysql/data --user=_mysql
8. 设置root密码:
sudo /usr/local/server/mysql/bin/mysqladmin -u root password 'mysql'
9.启动mysql:
sudo /usr/local/server/mysql/bin/mysqld_safe --user=_mysql &
10. 测试安装是否成功:
/usr/local/server/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
php编译安装:
1. 编译安装php:
./configure –prefix=/usr/local/server/php –with-config-file-path=/usr/local/server/php/etc –enable-fpm –with-openssl –with-zlib –enable-mbstring –with-mcrypt –with-mysql=/usr/local/server/mysql –with-mysql-sock=/tmp/mysqld.sock –with-mysqli=/usr/local/server/mysql/bin/mysql_config –enable-sockets –without-iconv –with-curl=/opt/local/bin/curl
2. 复制php.ini-development到编译时指定的php配制目录:
sudo cp php.ini-development /usr/local/server/php/etc/php.ini
3. 复制phpfpm的配置文件到其配制目录:
sudo cp php-fpm.conf.default php-fpm.conf
4. 重命名phpfpm执行文件为正常名称:
sudo mv php-fpm.dSYM php-fpm
5. 启动:
sudo /usr/local/server/php/sbin/php-fpm
6. 安装xdebug
1) 进入http://xdebug.org/find-binary.php网址, 输入phpinfo返回的html源码后其会自动生成安装步骤, 按照其方法编译安装, 最后变更php.ini配制文件指定xdebug.so扩展路径。
7. 安装phpunit
1) 升级pear.
sudo /usr/local/server/php/bin/pear upgrade
2) 安装phpunit.
sudo ./pear config-set auto_discover 1
sudo ./pear install pear.phpunit.de/PHPUnit
3) 测试phpunit是否安装成功.
/usr/local/server/php/bin/phpunit
#有输出帮助信息则为正常。
nginx编译安装:
1. 编译安装:
./configure --user=_www --group=_www --prefix=/usr/local/server/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module
make
sudo make install
2. 修改nginx配置:
sudo vim /usr/local/server/nginx/conf/nginx.conf
#指定程序运行权限:
user _www _www;
#在http内添加一条server信息:
server {
listen 80;
server_name localhost;
root /var/www;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
}
3.启动:
sudo /usr/local/server/nginx/sbin/nginx
#没有任何返回则说明执行成功。
参考文章:
lnap最新方案 http://www.yunwei8.com/nginx/