摘要:在歷時(shí)兩天的折騰后,我想有必要總結(jié)一下經(jīng)驗(yàn),一方面自我梳理,方便以后用。另一方面也給其他碰到相同問(wèn)題的人提供方法。開(kāi)啟的時(shí)候可能會(huì)出現(xiàn)缺少配置文件缺少日志目錄的情況,參考以下命令啟動(dòng)。
在歷時(shí)兩天的折騰后,我想有必要總結(jié)一下經(jīng)驗(yàn),一方面自我梳理,方便以后用。另一方面也給其他碰到相同問(wèn)題的人提供方法。
安裝brew:(mac 下的包管理工具),在最新的 mac os 下是自帶的
在最新的 mac os 下,php 是自帶的
安裝nginx :brew install nginx
啟動(dòng) nginx:sudo nginx ,訪問(wèn) http://localhost:8080看是否正常訪問(wèn)
前面都不要更改服務(wù)器配置但是接下來(lái)就厲害了,重點(diǎn)?。?!
廢話不多說(shuō)直接上配置文件nginx.conf
#user *root*; worker_processes 1; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } 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; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 8080; server_name localhost; #charset koi8-r; # access_log logs/host.access.log main; location / { root /Users/qsong/Desktop/MILANJUJIA/public; index index.php 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 127.0.0.1:80 # #location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # *location ~ .php$ { root /Users/qsong/Desktop/MILANJUJIA/public; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }* # deny access to .htaccess files, if Apache"s document root # concurs with nginx"s one # #location ~ /.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} include servers/*; }
想要配置多個(gè)項(xiàng)目的可以在server下添加項(xiàng)目配置(注意保持最后一行配置 include server/*打開(kāi)),在 server 下每個(gè)項(xiàng)目對(duì)應(yīng)一個(gè)配置文件,下面是我的一個(gè)配置文件
server { listen 8995; server_name localhost; access_log access_default.log ; location / { root /Users/qsong/Desktop/MILANJUJIA/public; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ .php$ { root /Users/qsong/Desktop/MILANJUJIA/public; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /.ht { deny all; } }
完成這些后按道理就可以從不同端口訪問(wèn)項(xiàng)目了,但這之前還需開(kāi)啟 php-fpm。
開(kāi)啟的時(shí)候可能會(huì)出現(xiàn)缺少配置文件、缺少日志目錄的情況,參考以下命令啟動(dòng)。
php-fpm --fpm-config /usr/local/etc/php/7.0/php-fpm.conf --prefix /usr/local/var
到這里應(yīng)該就完成了 nginx 和 php的部署
mysql
安裝的教程很多,這里不多說(shuō)。這里說(shuō)一下如果碰到不能登入 mysql (未設(shè)置密碼)的情況進(jìn)入mysql的安全模式
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
現(xiàn)在就可以直接執(zhí)行 mysql 進(jìn)入 mysql命令行
修改密碼
UPDATE mysql.user SET authentication_string=PASSWORD("123456") where User="root"; //將root用戶密碼改成 123456 flush privileges; //更新配置
重啟 mysql就可以登入
mysql -u root -p 123456
至此,php、php-fpm、nginx、mysql 配置完畢
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/22112.html
摘要:在歷時(shí)兩天的折騰后,我想有必要總結(jié)一下經(jīng)驗(yàn),一方面自我梳理,方便以后用。另一方面也給其他碰到相同問(wèn)題的人提供方法。開(kāi)啟的時(shí)候可能會(huì)出現(xiàn)缺少配置文件缺少日志目錄的情況,參考以下命令啟動(dòng)。 在歷時(shí)兩天的折騰后,我想有必要總結(jié)一下經(jīng)驗(yàn),一方面自我梳理,方便以后用。另一方面也給其他碰到相同問(wèn)題的人提供方法。 安裝brew:(mac 下的包管理工具),在最新的 mac os 下是自帶的 在最新...
摘要:一些關(guān)于在最新下搭建開(kāi)發(fā)環(huán)境的流程建議,直接進(jìn)入正題安裝開(kāi)發(fā)常用包軟件又叫,是上的軟件包管理工具,能在中方便的安裝軟件或者卸載軟件,和系統(tǒng)中的非常相似,只需要一個(gè)命令,非常方便。 一些關(guān)于在最新 Macos 下搭建LNMP開(kāi)發(fā)環(huán)境的流程建議,直接進(jìn)入正題: Preparing安裝 Homebrew、Ohmyzsh、開(kāi)發(fā)常用包&軟件 1.1 Homebrew Homebrew又叫Br...
閱讀 1285·2023-04-25 19:10
閱讀 1159·2021-09-10 10:50
閱讀 3042·2021-09-02 15:21
閱讀 1401·2019-08-30 15:52
閱讀 1697·2019-08-30 13:56
閱讀 2099·2019-08-30 12:53
閱讀 1886·2019-08-28 18:22
閱讀 2136·2019-08-26 13:47