我是NGINX(和bash)的新手,我正在尝试编写一个bash脚本来自动创建一个新站点(因此添加服务器块)到Web服务器。但是出于某种原因,我的脚本似乎将我带入了重定向循环。有任何想法吗?
cd /var/www/
git clone git@bitbucket.org:wardy484/portfolio.git
mv portfolio kimward.co.uk
sudo chmod -R 755 kimward.co.uk
FILE="/etc/nginx/sites-available/kimward.co.uk"
/bin/cat <<EOM >$FILE
server {
listen 80;
listen [::]:80;
root /var/www/kimward.co.uk/public;
index index.php index.html index.htm;
server_name kimward.co.uk www.kimward.co.uk;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
EOM
sudo nano /etc/nginx/sites-available/kimward.co.uk
sudo ln -s /etc/nginx/sites-available/kimward.co.uk /etc/nginx/sites-enabled/
sudo service nginx restart
cd /var/www/kimward.co.uk
composer install
composer update
答案 0 :(得分:1)
$uri
,$url
,$query_string
等是nginx个变量,需要进行转义,或者它们会被shell扩展:
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
其他特殊字符的情况可能相同。您不必使用<< 'EOM'
,而是必须使用file="/etc/nginx/sites-available/kimward.co.uk"
/bin/cat <<'EOM' >"$file"
server {
listen 80;
listen [::]:80;
...
...
EOM
将此文档视为单引号字符串。
$FILE
我还降低了$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/path/to/libc++.so
$ ./aapt -version
Android Asset Packaging Tool
Usage:
aapt l[ist] [-v] [-a] file.{zip,jar,apk}
List contents of Zip-compatible archive.
,因为所有大写名称都是为环境变量保留的。