鍍金池/ 問答/ Linux問答
葬愛 回答

try_files是可以的,不會響應(yīng)30x跳轉(zhuǎn)

location /oper/ {
    try_files $uri /index.html;
}

也可以用rewrite

location /oper/ {
    rewrite /oper/ /index.html last;
}

對比下兩者的優(yōu)缺點:
try_files可以兼顧文件存在的情況,不過會多一些磁盤操作
rewrite無磁盤操作,不過無法兼顧文件存在的情況

如果是單純的需要將/oper/開頭的所有請求返回/index.html,建議使用rewrite

拮據(jù) 回答

在容器中的/etc/nginx/目錄下

囍槑 回答

提供一個思路——先根據(jù)docker鏡像反向生成Dockerfile,再來具體看看。
有這么一個庫dockerfile-from-image能做這件事,不過這個庫已經(jīng)沒有維護了,我fork了一下改了點東西dockerfile-from-imagepush到了cloud.docker.com,然后你可以執(zhí)行一下命令:

docker pull fanjieqi/dockerfile-from-image:latest
alias dfimage="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock fanjieqi/dockerfile-from-image:latest"

dfimage <tag>/<image>:<version>

這樣能完整的展示這個鏡像的Dockerfile,不過當中add和copy這些命令操作的文件及文件夾都是帶了hash的,只能去猜操作的都是什么文件及文件夾,類似于這樣:

FROM node:9-alpine
WORKDIR /app
COPY file:7668b48cb0ef6effedbfcabe6e44cb7c70922fc63cf9e1a8fe2a259173835186 in /app
RUN npm install --production --registry=https://registry.npm.taobao.org
RUN echo -e "https://mirrors.ustc.edu.cn/alpine/latest-stable/main\nhttps://mirrors.ustc.edu.cn/alpine/latest-stable/community" > /etc/apk/repositories && apk update && apk add ca-certificates bash git openssh wget && update-ca-certificates && rm -rf /var/lib/apt/lists/*
COPY dir:1a399e39f0bccf78b41ba08e1876cbb222b21475a24c80341ff413b5a0b90b67 in /app

希望能幫助到你。

冷咖啡 回答

似乎這種語法實踐中行不通,(或許是版本限制),不過你說的//可以繞過空格或者當注釋符,你可以用/!/內(nèi)聯(lián)注釋,像這種測試你都可以本地執(zhí)行你的注入語句
從網(wǎng)上匯集的一些姿勢不知能不能幫到你

壞脾滊 回答

raise SystemExit('custome Error messega') 不僅輸出錯誤信息,還能返回錯誤代碼-1

挽青絲 回答
location /zhoulujun {
    rewrite ^/(.*)$ http://www.zhoulujun.cn/zhoulujun/index.php permanent;
}

location / {
    ...
}

你是要這個效果嗎?

嘟尛嘴 回答

既然你搞不定,建議還是去掉這功能比較好。
否則后面一堆問題等著你。

款爺 回答

static:: 對變量一般是指當前對象下的變量
比如說 父類有個屬性 叫 xxx,子類也有個屬性叫xxx,
父類有個方法doxxx,
當子類調(diào)用doxxx 這個方法時,
doxxx 里面去 static::xxx 就是取到的子類的,而不是父類的。
laravel 這個$app應(yīng)該是指當前應(yīng)用這個大對象

情已空 回答

可以,在app.js里定義

Vue.prototype.$test=false
v-if="$test"
我不懂 回答

第一種方法

試過在module1-service中添加自定義datasource(只支持properties,Yml可能能實現(xiàn),但還不太會寫),可以實現(xiàn)(此種方式不清楚是否會影響原來spring datasource機制,對spring原理不熟)
代碼如下:

@Component
@ConfigurationProperties(prefix = "spring.datasource")
@PropertySource("classpath:service-jdbc.properties")
public class MyDataSourceProperties {
    private String url;
    ...
}
@EnableConfigurationProperties(MyDataSourceProperties.class)
public class MyDataSourceConfig {
    @Autowired
    private MyDataSourceProperties myDataSourceProperties;
    @Bean
    @Primary
    public DataSource dataSource() {
        return DataSourceBuilder.create(myDataSourceProperties.getClassLoader()).type(myDataSourceProperties.getType()).driverClassName(myDataSourceProperties.determineDriverClassName()).url(myDataSourceProperties.determineUrl()).username(myDataSourceProperties.determineUsername()).password(myDataSourceProperties.determinePassword()).build();
    }
}

完整代碼:https://gitee.com/soft_xiang/...

第二種方法

在module1-service中自定義properties bean(此種方法較好,推薦),代碼如下

@Configuration
public class ServiceConfig {
    @Bean
    public static PropertySourcesPlaceholderConfigurer properties() {
        PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        yaml.setResources(new ClassPathResource("application-module1-service.yml"));
        configurer.setProperties(yaml.getObject());
        return configurer;
    }
}

由第二種用法引起的新的問題:

項目中如果存在多環(huán)境配置文件,如application-module1-service-dev.yml/application-module1-service-test.yml/application-module1-service/-release.yml時,怎樣根據(jù)module1-web中配置的spring.profiles.active加載對應(yīng)的配置文件?
思路為在加載文件時使用SpringContextUtil獲取配置文件中的active,在properties()中根據(jù)active加載文件
代碼如下:

SpringContextUtil.java

@Order(Integer.MIN_VALUE)
@Component
public class SpringContextUtil implements ApplicationContextAware {

    private static ApplicationContext context = null;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext)
            throws BeansException {
        this.context = applicationContext;
    }
    /// 獲取當前環(huán)境
    public static String getActiveProfile() {
        return context.getEnvironment().getActiveProfiles()[0];
    }
    /// 獲取當前環(huán)境
    public static String[] getActiveProfiles() {
        return context.getEnvironment().getActiveProfiles();
    }
}

ServiceConfig

    @Bean
    public static PropertySourcesPlaceholderConfigurer properties() {
        PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        String path = "application-module1-service.yml";
        try {
            String profile = SpringContextUtil.getActiveProfile();
            if (StringUtils.isNotBlank(profile)) {
                path = "application-module1-service-" + profile + ".yml";
            }
        }catch (NullPointerException e){
            e.printStackTrace();
            System.out.println("SpringContextUtil...未加載...");
        }
        YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        yaml.setResources(new ClassPathResource(path));//File引入
        configurer.setProperties(yaml.getObject());
        return configurer;
    }

完整代碼:https://gitee.com/soft_xiang/...

然而這里會有循環(huán)依賴問題
運行代碼會有

SpringContextUtil...未加載...

沒有實現(xiàn)根據(jù)active加載對應(yīng)配置文件

別瞎鬧 回答

給你個明確的說法:是跑在多核心上的。當然中間還有一大堆調(diào)用鏈、各種模型、操作系統(tǒng)、JVM的知識,但這些對你這個問題不重要。粗淺的理解,就當是多個 java 線程同時塞到 CPU 里面去;一個線程像面條一樣插在一個 cpu 核心孔里,然后從這頭拉出來(完成計算),就行了。

而且我猜測你要解決的問題,可以使用多線程去做,放心大膽去做,是能達到你要的最終結(jié)果的。但一般并不是線程越多越好,對于解決一個整體的計算問題,最終僅是一次計算而想得到整體結(jié)果的情況,我們一般的做法,是開的線程數(shù)量等于 CPU 的核心數(shù)量,這樣可以減少不必要的資源切換從而更利于效率。

那么,對于解決整體中含有不定量個體的問題,你可以先把整體數(shù)量除以 CPU 核心數(shù)量,得到一個進位整數(shù),然后對集合進行數(shù)量切割,每個小組再啟動一個線程去處理,最后合并結(jié)果集。

當然,這種情況下,你如果能使用 java 的 forkjoin 框架來解決,會優(yōu)雅很多。

https://www.roncoo.com/articl...

在兩臺不同的虛擬機上操作吧。

一臺跑兩個MySQL可能會有問題。即便沒問題,不能保證你做的實驗放在兩臺上也可以。

淚染裳 回答

你可以看看rust語言的設(shè)計

墻頭草 回答

切換到目標分支上, 假如當前狀態(tài)為新合并進了一條commit,只需執(zhí)行 git reset --hard HEAD~1即可回退到合并前。

或者回退到任何你想要的狀態(tài)中 git reset --hard commitId, 其中commitId為你想要處于的版本hash code。

心癌 回答

字體不對吧,換個字體

clipboard.png

互擼娃 回答

一個簡單的方式約束用戶在他們的家目錄
1,確保你安裝的openssh版本為4.9p1或高于該版本
2,編輯/etc/ssh/sshd_config
添加以下內(nèi)容
Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no

確?!癿atch”指令在文件末尾,這會告訴openssh,所有處于sftp組的用戶,限制他們的家目錄。

3,添加你想限制的用戶到sftp組
usermod -G sftp joe
usermod -s /bin/false joe
chown root:root /home/joe
chmod 0755 /home/joe

改組用戶沒有shell權(quán)限,可用chown和chmod設(shè)置目錄權(quán)限,當設(shè)置這些權(quán)限的時候,用戶可以上傳或下載
文件,但不能創(chuàng)建目錄或文件在根目錄,換句話說,如果這些用于web集群,確保子目錄在根下,如/home/joe/public_html/ 用戶有效且擁有所有權(quán),這種方式用戶可以在/home/joe/public_html下寫和創(chuàng)建目錄,但是不能自己改變根目錄(/home/joe)

在chroot里創(chuàng)建一個基本的系統(tǒng)

mkdir /chroot

cd /chroot

mkdir {bin,dev,lib}

cp -p /bin/bash bin/

cp -p /lib/{ld-linux.so.2,libc.so.6,libdl.so.2,libtermcap.so.2} lib/

mknod dev/null c 1 3

mknod dev/zero c 1 5

chmod 0666 dev/{null,zero}

mkdir -p /chroot/home/joe

用戶joe可以遠程受限的目錄,通常的情況下,這種作法不常見,但給了你一個思路,你可以安裝庫和二進制文件在受限目錄中。

厭遇 回答

建議重新配置下密鑰,一般都是這個的問題

脾氣硬 回答
http://localhost/play?make=movie&id=fqvnYxH4QnH1UB.html

http://localhost/play?movie/fqvnYxH4QnH1UB.html
RewriteRule ^\/play\?([^\/]+)\/([^\/]+)\.html$ /play?make=$1&id=$2