笔者对于这种配置安装的东西最为头大,本地自带的阿帕奇对于代理服务这块还是不太明白,迫于生计,么的办法,还是得学着安装这个玩意。
1.安装brew
没错,首先得安装这个brew
,然后通过brew命名去安装nginx
,网上大多是这种方案吧。
这里主要是针对于nginx
的配置问题,对于brew
的安装还是参照下给的链接吧,笔者这里安装的是中科大的版本。
2.安装nginx:
brew install nginx
:直接安装即可,这里没有sudo
,也就是不需要管理员权限
nginx -v
:查看到版本号即为安装成功。
3.nginx的启动以及相关文件的配置
cd /usr/local/etc/nginx
:进入安装路径文件夹vim nginx.conf
:打开配置文件
这里我的配置文件内容如下:
#user nobody;
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 9200;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /expertReview {
alias "/Users/xuyongqi/jobs/expertReview";
index index.html index.htm;
## 当出现405错误时,将采用后面地址进行重新请求
error_page 405 =200 http://$host:$server_port$request_uri;
}
location /idtAppServiceV6 {
# proxy_pass http://39.105.123.5:9090/idtAppServiceV6;
# proxy_pass http://199.66.68.4:8001/idtAppServiceV6;
# proxy_pass http://199.66.68.30:6099/idtAppServiceV6;
proxy_pass http://199.66.68.83:18080/idtAppServiceV6;
# proxy_pass http://199.66.68.61:18084/idtAppServiceV6;
# proxy_set_header Cookie 'theworld_client_none=yyyyz';
# proxy_set_header Host $host;
}
location /platformv6 {
# proxy_pass http://199.66.68.83:18080/platformv6;
# proxy_set_header Cookie 'theworld_client_none=yyyyz';
# proxy_set_header Host $host;
}
#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 html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$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/*;
}
复制代码
4.关于mac下自定义常用命令行:
-
vim ~/.bash_profile
:设置环境变量、路径
以及自定义全局命令
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm export ANDROID_HOME=/Users/xuyongqi/Library/Android/sdk export PATH=${PATH}:${ANDROID_HOME}/platform-tools export PATH=${PATH}:${ANDROID_HOME}/tools export PATH=${PATH}:${ANDROID_HOME}/build-tools/28.0.3 export PATH=${PATH}:/usr/local/mysql/bin export PATH=${PATH}:/usr/local/mongodb/bin export PATH=${PATH}:~/Library/Android/sdk/platform-tools alias start-sql="sudo /usr/local/mysql/support-files/mysql.server start" alias stop-sql="sudo /usr/local/mysql/support-files/mysql.server stop" alias start-nginx="brew services start nginx" alias stop-nginx="brew services stop nginx" 复制代码
- 这里我设置的
start-sql
、stop-sql
等就是启动和关闭mysql
的自定义命令,会带来很多方便吧
- 这里我设置的
-
source .bash_profile
:使上述等配置文件的改动立即生效;
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END