国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

mac搭建nginx和wordpress開發環境

trigkit4 / 3538人閱讀

摘要:第一步關閉及開機啟動要使用,最好停用中自帶的。解壓后將目錄下的所有文件放到網站根目錄下如。設置本地域名打開文件,另起一行輸入,保存文件。

對于不懂后端的我,做這件事真是受盡折磨。 在不懈努力下,終于成功。 下面寫下筆記,與大家分享。

第一步:關閉Apache及開機啟動

要使用nginx,最好停用mac中自帶的Apache。停用很簡單:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

第二步:安裝homebrew

homebrew是mac下的包管理器,類似于linux下的yumapt。使用homebrew安裝nginxphpmysql要比手動安裝方便很多。官網地址:http://brew.sh/index_zh-cn.html

安裝:

sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

第三步:安裝nginx

安裝:brew install nginx

啟動:sudo nginx

停止:sudo nginx -s quit

配置nginx:

/usr/local/var/log/nginx/下,新建文件:access.logerror.log

配置/usr/local/etc/nginx/nginx.conf

#user  nobody;
worker_processes  1;

error_log  /usr/local/var/log/nginx/error.log;

pid        /usr/local/var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    access_log  /usr/local/var/log/nginx/access.log;
    sendfile        on;
    keepalive_timeout  65;

    #
    include conf.d/*.conf;
}

/usr/local/etc/nginx/下,新建文件夾conf.d。在conf.d/下,新建文件default.conf,配置default.conf

    server {
        listen       80  default_server;
        server_name  localhost;    #域名,自定義
        root   網站根目錄;    #自定義,如/var/www
        index  index.html index.htm
    }

測試:在你設定的根目錄下(例如/var/www/),新建一個靜態頁index.html,啟動nginx,在瀏覽器中輸入localhost,成功看到靜態頁內容。

第四步:安裝php

首先,在brew中添加php的源:

brew tap josegonzalez/php

brew tap homebrew/dupes

查看已添加的源:brew tap

搜索可安裝的php:brew search php
一看結果,我靠,怎么這么多!不懂php的我,完全不懂這些是什么東西。 不過不用管他們。只要知道該安裝哪些就好。

看到別人安裝最多的是php55,安裝前首先查看一下安裝相關參數的說明:

brew search php55

結果:

--disable-opcache
    Build without Opcache extension
--homebrew-apxs
    Build against apxs in Homebrew prefix
--with-apache
    Enable building of shared Apache 2.0 Handler module, overriding any options which disable apache
--with-cgi
    Enable building of the CGI executable (implies --without-apache)
--with-debug
    Compile with debugging symbols
--with-enchant
    Build with enchant support
--with-fpm
    Enable building of the fpm SAPI executable (implies --without-apache)
--with-gmp
    Build with gmp support
--with-homebrew-curl
    Include Curl support via Homebrew
--with-homebrew-libxslt
    Include LibXSLT support via Homebrew
--with-homebrew-openssl
    Include OpenSSL support via Homebrew
--with-imap
    Include IMAP extension
--with-libmysql
    Include (old-style) libmysql support instead of mysqlnd
--with-mssql
    Include MSSQL-DB support
--with-pdo-oci
    Include Oracle databases (requries ORACLE_HOME be set)
--with-phpdbg
    Enable building of the phpdbg SAPI executable (PHP 5.4 and above)
--with-postgresql
    Build with postgresql support
--with-thread-safety
    Build with thread safety
--with-tidy
    Include Tidy support
--without-bz2
    Build without bz2 support
--without-mysql
    Remove MySQL/MariaDB support
--without-pcntl
    Build without Process Control support
--without-pear
    Build without PEAR
--without-snmp
    Build without SNMP support
--HEAD
    Install HEAD version

沒搞明白這些是什么意思,先這么裝吧:

brew install php55 --with-fpm, --with-enchant, --with-debug

成功安裝后,啟動php-fpm:(php-fpm相當于一個接口,nginx和php之間通信通過php-fpm這個東西)

launchctl load -w /usr/local/opt/php55/homebrew.mxcl.php55.plist

停止php-fpm:

launchctl unload -w /usr/local/opt/php55/homebrew.mxcl.php55.plist

設置快捷指令:打開~/.bash_profile,添加

alias php55.start=launchctl load -w /usr/local/opt/php55/homebrew.mxcl.php55.plist
alias php55.stop=launchctl unload -w /usr/local/opt/php55/homebrew.mxcl.php55.plist

快捷指令設置之后,重啟shell,就可以用php55.startphp55.stop來啟動和停止php-fpm了。

重新配置nginx:配置文件/usr/local/etc/nginx/conf.d/default.conf

    server {
        listen       80  default_server;
        server_name  localhost;    #域名,自定義
        root   網站根目錄;    #自定義,如/var/www
        index  index.html index.htm

        # pass the PHP scripts to FastCGI slinerver listening on 127.0.0.1:9000
        #
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME   網站根目錄$fastcgi_script_name;   #如/var/www$fastcgi_script_name
            include        fastcgi_params;
            fastcgi_intercept_errors on;
        }
    }

測試:重啟nginx,啟動php-fpm后,在網站根目錄下新建文件index.php,設置index.php的內容:。然后瀏覽器中輸入:localhost/index.php,看到php信息,成功。

第五步:安裝mysql

安裝:brew install mysql

啟動:launchctl load -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist

停止:launchctl unload -w /usr/local/opt/php55/homebrew.mxcl.php55.plist

設置快捷指令:同php-fpm快捷指令一樣,打開~/.bash_profile,添加

alias mysql.start=launchctl load -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
alias mysql.stop=launchctl unload -w /usr/local/opt/mysql/homebrew.mxcl.mysql.plist

初始化mysql:運行/usr/local/opt/mysql/bin/mysql_secure_installation 將有一個向導知道你一步一步設定安全和配置信息。

安裝phpmyadmin: 在http://www.phpmyadmin.net/home_page/downloads.php下載最新版的phpmyadmin,解壓后將目錄下的所有文件放到網站根目錄/phpmyadmin下(如/var/www/phpmyadmin),然后瀏覽器中輸入localhost/phpmyadmin出現首頁,輸入數據庫賬號(root)和密碼,登陸成功。

第六步:安裝wordpress

下載:從https://wordpress.org/download/上下載最新版的wordpress。
解壓后將目錄下的所有文件放到網站根目錄/wordpress下(如/var/www/wordpress)。

設置本地域名:打開文件/etc/hosts,另起一行輸入127.0.0.1 mywordpress,保存文件。

我遇到一件很頭疼的事:明明nginx,php,mysql都沒有問題,可是每當初始化wordpress總會遇到nginx報錯:

google一查,原來wordpress官方專門有個配置nginx的教程:http://codex.wordpress.org/Nginx

重新配置nginx

配置/usr/local/etc/nginx.conf

#user  nobody;
worker_processes  1;

error_log  /usr/local/var/log/nginx/error.log;

pid        /usr/local/var/run/nginx.pid;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    access_log  /usr/local/var/log/nginx/access.log;
    sendfile        on;
    keepalive_timeout  65;

    #php max upload limit cannot be larger than this
    client_max_body_size 13m;
    index              index.php index.html index.htm;

    # Upstream to abstract backend connection(s) for PHP.
    upstream php {
      #this should match value of "listen" directive in php-fpm pool
      #server unix:/tmp/php-fpm.sock;
        server 127.0.0.1:9000;
    }

    #
    #
    include conf.d/*.conf;
}

/usr/local/etc/nginx/下新建目錄global,在/usr/local/etc/nginx/global/下新建文件添加文件restrictions.confwordpress.conf,分別添加如下內容:

restrictions.conf:

# Global restrictions configuration file.
# Designed to be included in any server {} block.

location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~ /. { deny all; } # Deny access to any files with a .php extension in the uploads directory # Works in sub-directory installs and also in multisite network # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) location ~* /(?:uploads|files)/.*.php$ { deny all; }

wordpress.conf:

# WordPress single blog rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
  try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ [^/].php(/|$) {
  fastcgi_split_path_info ^(.+?.php)(/.*)$;
  if (!-f $document_root$fastcgi_script_name) {
    return 404;
  }
  # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)

  include fastcgi.conf;
  fastcgi_index index.php;
#   fastcgi_intercept_errors on;
  fastcgi_pass php;
}

/usr/local/etc/nginx/conf.d/下新建文件 mywordpress.conf,配置文件內容

server {
  server_name mywordpress;
  root 網站根目錄/mywordpress;  #自定義,如/var/www/mywordpress

  index index.php;

  include global/restrictions.conf;
  include global/wordpress.conf;
}

最后一步:重啟nginx,啟動php-fpm和mysql,在瀏覽其中輸入mywordpress,出現初始化向導,按照向導設置數據庫信息,然后成功。


如有問題歡迎留言與我聯系! 或者郵箱:linchen.1987@foxmail.com

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/39119.html

相關文章

  • mac搭建nginxwordpress開發環境

    摘要:第一步關閉及開機啟動要使用,最好停用中自帶的。解壓后將目錄下的所有文件放到網站根目錄下如。設置本地域名打開文件,另起一行輸入,保存文件。 對于不懂后端的我,做這件事真是受盡折磨。 在不懈努力下,終于成功。 下面寫下筆記,與大家分享。 第一步:關閉Apache及開機啟動 要使用nginx,最好停用mac中自帶的Apache。停用很簡單: sudo launchctl unload ...

    leejan97 評論0 收藏0
  • 新興的web服務器caddy

    摘要:是一個像或的服務器。得益于的特性,只是一個小小的二進制文件,沒有依賴,很好部署。我們來試試在當前目錄創建這樣一個叫的文件這次,我們改變了端口,并且啟用了自動壓縮數據。據說全世界四分之一的站點都是搭建的,而公認是世界上最好的語言。 caddy 是一個像 Apache, nginx, 或 lighttpd 的web服務器。你要問nginx已經很好了,為什么要用caddy呢? 我覺得cadd...

    CollinPeng 評論0 收藏0
  • ECS+nginx+wordpress一手搭建完畢

    摘要:先來一段吐槽好朋友校招進百度前端團隊了我還在找工作好心塞但是蠻為他高興的是我的問題技術面鋪的太開了,沒有深入的一項比較深入的也就是滲透,了吧但是滲透團隊要求好高網易跪在了面綠盟進行中工資略低啊技能點大概是星滿分星星滲透星星網絡安全星,學習能 PS: 先來一段吐槽...好朋友校招進百度前端團隊了..我還在找工作ing..好心塞.但是蠻為他高興的. 是我的問題.技術面鋪的太開了,沒有深...

    ityouknow 評論0 收藏0
  • 手把手教你基于WordPress搭建自己的個人博客

    摘要:一步一步教你基于搭建自己的個人博客,作為成熟的框架,美觀,方便,插件多,更新頻繁,非常適合個人博客與網站的搭建,適合新手,無需太多的代碼基礎。原文鏈接手把手教你搭建自己的網站購買購買云服務器為了搭建個人網站,首先肯定需要一個云服務器。 一步一步教你基于WordPress搭建自己的個人博客,WordPress作為成熟的CMS框架,美觀,方便,插件多,更新頻繁,非常適合個人博客與網站的搭建...

    vpants 評論0 收藏0
  • 如何借助騰訊云從0到1搭建自己的互聯網領地

    摘要:以下為文章的原文項目簡介通過使用騰訊云多種產品證書并配合使用知名系統,從無到有打造一個自己在互聯網空間中的自留地。戰前準備擁有一個已經在騰訊云備案成功的域名。 推薦理由: 今天我在騰訊云技術社區—騰云閣看到一篇文章,我感覺對我們這些小白進軍互聯網很有幫助,讓我重新認識了云端的部署和構架,以及對云服務器、云數據庫、CDN、云安全、萬象圖片和云點播等產品的一個了解,在此我也想給大家分享一下...

    marek 評論0 收藏0

發表評論

0條評論

最新活動
閱讀需要支付1元查看
<