MacOSX下安装NginxPHPMysql.doc_第1页
MacOSX下安装NginxPHPMysql.doc_第2页
MacOSX下安装NginxPHPMysql.doc_第3页
MacOSX下安装NginxPHPMysql.doc_第4页
MacOSX下安装NginxPHPMysql.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

揭示:如果不习惯使用vi编辑器,可以将sudo vi替换成系统默认的文本编辑工具,例如sudo vi /etc/hosts替换成sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts1.安装XcodeXcode可以去apple官网上去下载,默认系统不包含gcc等编译器,安装完Xcode就会有相应的开发编译环境。2.删除默认的PHP如果要删除系统默认安装的Apache与PHP,可以将如下列表的文件删除,这个步骤可以不用执行。/usr/bin/php/usr/bin/php-config/usr/bin/phpize/usr/include/php/usr/lib/php/usr/share/man/man1/php.1.gz/usr/share/man/man1/php-config.1.gz/usr/share/man/man1/phpize.1.gz/etc/apache2/usr/libexec/apache23.安装libjpeg, mcrypt,libmcrypt,mhash,autoconf 2.13,cmake安装jpegv8ctar xvzf jpegsrc.v8c.tar.gzcd jpeg-8c./configure -prefix=/usrmakesudo make install安装mhashtar zxvf mhash-.tar.gzcd mhash-/./configure -prefix=/usrmakesudo make install安装libmcrypttar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8/./configure -prefix=/usr -disable-posix-threads -enable-static如果出现如下错误checking host system type configure: error: can not guess host type; you must specify one执行如下复制命令,将系统中的文件复制到当前目录下cp /usr/share/libtool/config/config.* .makesudo make install安装mcrypttar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8/./configure -prefix=/usrmakesudo make installrfc2440.c:26:20: error: malloc.h: No such file or directory.make1: * rfc2440.o Error 1make: * install-recursive Error 1如果出现如上错误,修改文件src/rfc2440.c,修改26行#include 修改为:#include 安装autoconf 2.13由于安装php-fpm需要重新创建编译文件,系统默认的autoconf版本过高,导致重建通不过。tar xvzf autoconf-2.13.tar.gzcd autoconf-2.13./configure -prefix=/usr/local/autoconf213makesudo make install安装cmake由于编译安装mysql 5.5以上版本,需要使用cmake编译工具tar xvzf cmake-2.8.4.tar.gzcd cmake-2.8.4./configure -prefix=/usr/local/cmakemakesudo make install4.安装mysqlmysql需要下载源代码版本,去mysql网站/downloads/mysql/Select Platform选择Source Code下载Generic Linux (Architecture Independent), Compressed TAR Archivetar xvzf mysql.5.5.10.tar.gzcd mysql.5.5.10CFLAGS=-O3 -fno-omit-frame-pointerCXXFLAGS=-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti/usr/local/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5.10 -DMYSQL_DATADIR=/usr/local/mysql5.5.10/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DMYSQL_UNIX_ADDR=/usr/local/mysql5.5.10/data/mysql.socket -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_READLINE=1makesudo make install设置配置文件,可以不做,会载入默认设置在类unix操作系统下,配置文件f搜索顺序为:/etc/fmysq_install_dir/etc/f/.f为了让系统可以支持多版本的mysql,建议将f放置在mysq_install_dir下sudo mkdir /usr/local/mysql5.5.10/etcsudo cp support-files/f /usr/local/mysql5.5.10/etc/f修改目录权限cd /usr/local/sudo chgrp -R _mysql mysql5.5.10sudo chmod 775 mysql5.5.10生成 mysql 系统数据库cd mysql5.5.10sudo ./scripts/mysql_install_db -user=_mysql -datadir=/usr/local/mysql5.5.10/datasudo chown -R _mysql data启动mysqlsudo ./bin/mysqld_safe &修改 mysql 的 root 密码./bin/mysqladmin -u root password 123456将mysql下bin加入环境变量cd # 如果不存在文件.profile,创建touch .profile# 编辑文件vi .profile# 加入mysql的bin目录到PATH变量export PATH=$PATH:/usr/local/mysql5.5.10/bin用如下命令不用重启系统就可以激活新的配置. .profile将mysql加入系统启动sudo vi /Library/LaunchDaemons/com.mysql.mysqld5.5.10.plist文件内容 Label com.mysql.mysqld5.5.10 Program /usr/local/mysql5.5.10/bin/mysqld_safe UserName _mysql WorkingDirectory /usr/local/mysql5.5.10 KeepAlive RunAtLoad 通过launchd人工启动和停止MySQL服务装载服务:sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld5.5.10.plist卸载服务:sudo launchctl unload /Library/LaunchDaemons/com.mysql.mysqld5.5.10.plist在Mac上安装了MySQL 5.5,在php编译支持mysql的时候会出现如下错误。dyld: Library not loaded: libmysqlclient.18.dylib Referenced from: /usr/local/bin/sysbench Reason: image not foundTrace/BPT trap原因是由于libmysqlclient.dylib的id路径是相对路径而不是绝对路径,这应该是MySQL打包的时出的问题。运行如下命令otool -DX /usr/local/mysql5.5.10/lib/libmysqlclient.dylib显示libmysqlclient.18.dylib则表示有问题需要修复正常情况应该是下面这样:otool -DX /usr/local/mysql5.5.10/lib/libmysqlclient.dylib显示/usr/local/mysql5.5.10/lib/libmysqlclient.18.dylib则表示正常如何修复:sudo install_name_tool -id /usr/local/mysql5.5.10/lib/libmysqlclient.18.dylib /usr/local/mysql5.5.10/lib/libmysqlclient.dylib运行完上面的命令时,再用上面的命令otool检查一下。删除MySQL进入源代码文件夹:cd /src/mysql-5.5.10卸载:sudo make uninstall卸载MySQL服务:sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist删除com.mysql.mysqld5.5.10.plist文件:sudo rm /Library/LaunchDaemons/com.mysql.mysqld5.5.10.plist注意,如果你在安装完MySQL后,删除了/src文件夹和里面的所有文件,想要卸载MySQL时,你需要重新建立src文件夹,下载同样的源代码,解压缩,配置,编译,最后才能使用make uninstall命令卸载MySQL,所以,没有必要删除src文件夹。5.安装php安装PHP 5.2由于php5.2不包含php-fpm,需要通过补丁包tar zxvf php-5.2.17.tar.gzgzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1gzip -cd suhosin-patch-5.2.17-0.9.7.patch.gz | patch -d php-5.2.17 -p1cd php-5.2.17/export PHP_AUTOCONF=/usr/local/autoconf213/bin/autoconfexport PHP_AUTOHEADER=/usr/local/autoconf213/bin/autoheader./buildconf -force /一定要执行这一步./configure -prefix=/usr/local/php5.2.17 -with-config-file-path=/usr/local/php5.2.17/etc -with-mysql=/usr/local/mysql5.5.10 -with-pdo-mysql=/usr/local/mysql5.5.10 -with-mysqli=/usr/local/mysql5.5.10/bin/mysql_config -with-iconv-dir -with-freetype-dir=/usr/X11R6 -with-jpeg-dir -with-png-dir=/usr/X11R6 -with-xpm-dir=/usr/X11R6 -with-zlib -with-libxml-dir -enable-xml -enable-discard-path -enable-safe-mode -enable-bcmath -enable-shmop -enable-sysvsem -enable-inline-optimization -with-curl -with-curlwrappers -enable-mbregex -enable-fastcgi -enable-fpm -enable-force-cgi-redirect -enable-mbstring -with-mcrypt -with-gd -enable-gd-native-ttf -with-openssl -with-mhash -enable-pcntl -enable-sockets -with-ldap -with-ldap-sasl -with-xmlrpc -enable-zip -enable-soap -enable-ftp -disable-debug -disable-ipv6makesudo make installsudo cp php.ini-dist /usr/local/php5.2.17/etc/php.ini设置php配置文件sudo vi /usr/local/php5.2.17/etc/php.inidate.timezone = Asia/Shanghaipost_max_size = 50Mupload_max_filesize = 50Mmax_execution_time = 300max_input_time = 600修改php-fpm配置文件sudo vi /usr/local/php5.2.17/etc/php-fpm.conf设置端口:5217设置组和用户Unix user of processes_www Unix group of processes_www提示:-enable-fastcgi 需要在-enable-fpm 的前面,否则,fpm 不能编译上。php-fpm加入系统启动sudo vi /Library/LaunchDaemons/net.php.php5.2.17.fpm.plist Label net.php.php5.2.17.fpm ProgramArguments /usr/local/php5.2.17/sbin/php-fpm start RunAtLoad Stop:sudo /usr/local/php5.2.17/sbin/php-fpm stopStart:sudo launchctl load /Library/LaunchDaemons/net.php.php5.2.17.fpm.plist安装PHP 5.3php5.3版本已经内置支持php-fpm,所以不需要打补丁tar zxvf php-5.3.6.tar.gzcd php-5.3.6/./configure -prefix=/usr/local/php5.3.6 -with-config-file-path=/usr/local/php5.3.6/etc -with-mysql=/usr/local/mysql5.5.10 -with-pdo-mysql=/usr/local/mysql5.5.10 -with-mysqli=/usr/local/mysql5.5.10/bin/mysql_config -with-iconv-dir -with-freetype-dir=/usr/X11R6 -with-jpeg-dir -with-png-dir=/usr/X11R6 -with-xpm-dir=/usr/X11R6 -with-zlib -with-libxml-dir -enable-xml -enable-discard-path -enable-safe-mode -enable-bcmath -enable-shmop -enable-sysvsem -enable-inline-optimization -with-curl -with-curlwrappers -enable-mbregex -enable-fastcgi -enable-fpm -with-fpm-user=_www -with-fpm-group=_www -enable-force-cgi-redirect -enable-mbstring -with-mcrypt -with-gd -enable-gd-native-ttf -with-openssl -with-mhash -enable-pcntl -enable-sockets -with-ldap -with-ldap-sasl -with-xmlrpc -enable-zip -enable-soap -enable-ftp -disable-debug -disable-ipv6makesudo make installsudo cp php.ini-dist /usr/local/php5.3.6/etc/php.ini设置php配置文件sudo vi /usr/local/php5.3.6/etc/php.inidate.timezone = Asia/Shanghaipost_max_size = 50Mupload_max_filesize = 50Mmax_execution_time = 300max_input_time = 600修改php-fpm配置文件sudp cp /usr/local/php5.3.6/etc/php-fpm.conf.default /usr/local/php5.3.6/etc/php-fpm.confsudo vi /usr/local/php5.3.6/etc/php-fpm.confpid = run/php-fpm.pidlisten = :5306pm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35注意去掉开头的分号注释php-fpm加入系统启动sudo vi /Library/LaunchDaemons/net.php.php5.3.6.fpm.plist Label net.php.php5.3.6.fpm Program /usr/local/php5.3.6/sbin/php-fpm RunAtLoad 停止与重启sudo cp /Downloads/Applications/PHP/php-5.3.6/sapi/fpm/init.d.php-fpm /usr/local/php5.3.6/sbin/php-fpm-binsudo /usr/local/php5.3.6/sbin/php-fpm-bin start|stop昨天在Mac上安装了MySQL 5.5,准备用sysbench做个测试时,发现sysbench无法运行。$ sysbench dyld: Library not loaded: libmysqlclient.16.dylib Referenced from: /usr/local/bin/sysbench Reason: image not foundTrace/BPT trap原因是由于libmysqlclient.dylib的id路径是相对路径而不是绝对路径,这应该是MySQL打包的时出的问题。$ otool -DX ./libmysqlclient.dylib libmysqlclient.16.dylib正常情况应该是下面这样:$ otool -DX ./libmysqlclient.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib如何修复:$ sudo install_name_tool -id /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.dylib6.安装nginx安装nginx需要pcre源码包,所以先解压tar zxvf pcre-8.12.tar.gz解压即可,不需要安装tar zxvf nginx-0.8.54.tar.gzcd nginx-0.8.54./configure -user=www -group=www -prefix=/usr/local/nginx0.8.54 -with-http_stub_status_module -with-http_ssl_module -with-pcre=./pcre-8.12makesudo make install注意* with-pcre=./pcre-8.12指向的是源码包解压的路径,而不是安装的路径,否则会报make1: * /usr/local/pcre/Makefile Error 127 错误】nginx加入系统启动sudo vi /Library/LaunchDaemons/org.nginx.nginx0.8.54.plist Label nginx Program /usr/local/nginx0.8.54/sbin/nginx KeepAlive NetworkState StandardErrorPath /var/log/system.log LaunchOnlyOnce 加入系统启动sudo launchctl load -w /Library/LaunchDaemons/org.nginx.nginx0.8.54.plist启动服务sudo launchctl load /Library/LaunchDaemons/org.nginx.nginx0.8.54.plistsudo /usr/local/nginx0.8.54/sbin/nginx -s reload|stop7.配置虚拟主机sudo vi /usr/local/nginx0.8.54/conf/nginx.conf只需在http段区域内加上两段设置vhost的文件,以后设置虚拟主机只需要修改那两个文件就可以。# virtual hostsinclude vhost.conf;include vhost_ssl.conf;加入后nginx.conf文件如下:user _www _www;worker_processes 2;error_log logs/error.log crit;#error_log logs/error.log notice;#error_log logs/error.log info;pid logs/nginx.pid;events #use epoll; worker_connections 65535;http include mime.types; default_type application/octet-stream; log_format main $remote_addr - $remote_user $time_local $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for; #access_log logs/access.log main; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 1 128k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_buffers 2 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 1 64k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; server listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / root html; index index.html index.htm; #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html root html; # proxy the PHP scripts to Apache listening on :80 # #location .php$ # proxy_pass ; # # pass the PHP scripts to FastCGI server listening on :9000 # #location .php$ # root html; # fastcgi_pass :9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; # # deny access to .htaccess files, if Apaches document root # concurs with nginxs one # #location /.ht # deny all; # # virtual hosts include vhost.conf; include vhost_ssl.conf;创建虚拟主机配置文件sudo touch /usr/local/nginx0.8.54/conf/vhost.confsudo touch /usr/local/nginx0.8.54/conf/vhost_ssl.conf加入虚拟主机配置先创建工作目录mkdir -p /Working/Websites以后网站代码都放在这个目录下这次配置三个主机,phpmyadmin, drupal6,drupal7phpmyadmin使用php5.2drupal6使用php5.2drupal7使用php5.3创建三个目录mkdir /Working/Websites/www.mysql.localmkdir /Working/Websites/www.drupal6.localmkdir /Working/Websites/www.drupal7.local设置sudo vi /usr/local/ngingx0.8.54/conf/vhost.conf# HTTP server# mysql.localserver listen 80; server_name mysql.local; access_log logs/mysql.local.access.log main; root /Working/Websites/www.mysql.local/; index index.php index.html index.htm; location / if (-f $request_filename) expires 30d; break; location .php$ fastcgi_pass :5217; fastcgi_index index.php; include fastcgi.conf; # php 5.2.17#giga002server listen 80; server_name www.drupal6.local; rewrite /(.*) http:/drupal6.local permanent;server listen 80; server_name drupal6.local; access_log logs/drupal6.local.access.log main; root /Working/Websites/www.drupal6.local/; index index.php; location / try_files $uri $uri/ drupal; location /imagecache/ try_files $uri drupal; expires 45d; location drupal rewrite /(.*)$ /index.php?q=$1 last; error_page 404 /index.php; location .php$ fastcgi_pass :5217; fastcgi_index index.php; include fastcgi.conf; # protection for sensitive infolocation (/.*|settings.php$|.(htaccess|engine|inc|info|install|module|profile|pl|po|sh|.*sql|theme|tpl(.php)?|xtmpl)$|(Entries.*|Repository|Root|Tag|Template)$ deny all;# turn off access logs for stylesheets and scriptslocation .(cssjs)$ access_log off;# performance for imageslocation * .(jpg|jpeg|png|gif|ico)$ expires 45d;access_log off; # deny access to .htaccess files, if Apaches document root location /.ht deny all; # php 5.3.6# drupal7server listen 80; server_name www.drupal7.local; rewrite /(.*) http:/drupal7.local permanent;server listen 80; server_name

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论